⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 thresh.m

📁 边缘提取源码
💻 M
字号:
% Question No: 5

% Consider an image composed of small, no overlapping blobs. Segmenting the
% blobs based on thresholding.

function thresh(x)
f=imread(x);
f=im2double(f);
%global Thresholding
T=0.5*(min(f(:))+max(f(:)));
done=false;
while ~done
    g=f>=T;
    Tn=0.5*(mean(f(g))+mean(f(~g)));
    done=abs(T-Tn)<0.1;
    T=Tn;
end
display('Threshold(T) - Iterative');
T
r=im2bw(f,T);
figure,imshow(f),title('Original Image');
figure,imshow(r),title('Global Thresholding - Iterative Method');
Th=graythresh(f);
display('Threshold(T) - Otsu''s Method');
Th
s=im2bw(f,Th);
figure,imshow(s),title('Global Thresholding - Otsu''s Method');
%Local Thresholding
se=strel('disk',10);
ft=imtophat(f,se);
Thr=graythresh(ft);
display('Threshold(T) - Local Thresholding');
Thr
lt=im2bw(ft,Thr);
figure,imshow(lt),title('Local Thresholding');
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -