本文主要是介绍Matlab第二版(本科教学版),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
matlab程序
数字图像处理第二版(本科教学版)
第七章 图像分割
(注:代码原因,程序源码中笑脸😀符合都为:)
*例7.1 点检测
程序源码:
f = imread(“D:\photo\DIP3E_CH05_Original_Images\Fig0524(b)(blurred-impulse).tif”);
w = [-1 -1 -1;-1 8 -1;-1 -1 -1]; % 点Fig0524(b)(blurred-impulse)检测掩模
g = abs(imfilter(double(f),w));
T = max(g(😃);
g = g>=T;
subplot(1,2,1);imshow(f);title(‘(a)原图像’);
subplot(1,2,2);imshow(g);title(‘(b)点检测’);
例7.2 检测制定方向的线
程序源码:
f = imread(“D:\photo\DIP3E_Original_Images_CH09\Fig0905(a)(wirebond-mask).tif”); % 图像大小:486×486
w = [2 -1 -1;-1 2 -1;-1 -1 2]; % +45°方向检测线
g = imfilter(double(f),w);
gtop = g(1:120,1:120); % 左上角区域
gtop = pixeldup(gtop,4,4); % 通过复制像素将图像扩大gtop*4倍
gbot = g(end-119:end,end-119:end); % 右下角区域
gbot = pixeldup(gbot,4,4);
g1 = abs(g); % 检测图的绝对值
T = max(g1(😃);
g2 = g1>=T;
subplot(3,2,1);imshow(f);title(‘(a)连线模板图像’);
subplot(3,2,2);imshow(g,[]);title(‘(b)+45°线处理后的结果’);
subplot(3,2,3);imshow(gtop,[]);title(‘©(b)中左上角的放大效果’);
subplot(3,2,4);imshow(gbot,[]);title(‘(d)(b)中右下角的放大效果’);
subplot(3,2,5);imshow(g1,[]);title(‘(e)(b)的绝对值’);
subplot(3,2,6);imshow(g2);title(‘(f)满足g>=T的所有点’);
7.3 使用sobel边缘检测器
程序源码:
f = imread(“D:\photo\DIP3E_Original_Images_CH04\Fig0438(a)(bld_600by600).tif”); % 图像大小:486×486
subplot(3,2,1),imshow(f),title(‘(a)原始图像’);
[gv, t] = edge(f,‘sobel’,‘vertical’);
subplot(3,2,2),imshow(gv),title(‘(b)Sobel模板处理后结果’);
gv = edge(f, ‘sobel’, 0.15, ‘vertical’);
subplot(3,2,3),imshow(gv),title(‘©使用指定阈值的结果’);
gboth = edge(f, ‘sobel’, 0.15);
subplot(3,2,4),imshow(gboth),title(‘(d)指点阈值确定垂直边缘和水平边缘的结果’);
w45 = [-2 -1 0;-1 0 1; 0 1 2];
g45 = imfilter(double(f), w45, ‘replicate’);
T = 0.3 * max(abs(g45(😃));
g45 = g45 >= T;
subplot(3,2,5),imshow(g45),title(‘(e)-45°方向边缘’);
f45= [0 1 2;-1 0 1;-2 -1 0];
h45= imfilter(double(f), f45,‘replicate’);
T = 0.3 * max(abs(h45(😃));
h45 = h45 >= T;
subplot(3,2,6),imshow(h45),title(‘(f)+45°方向边缘’);
例7.4 Sobel、LoG、和Ganny边缘检测器的比较
程序源码:
f = imread(“D:\photo\DIP3E_Original_Images_CH04\Fig0438(a)(bld_600by600).tif”); % 图像大小:486×486
[g_sobel_default,ts] = edge(f,‘sobel’);
[g_log_default,tlog] = edge(f,‘log’);
[g_canny_default,tc] &#
这篇关于Matlab第二版(本科教学版)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!