%% 第九章 形态学图像处理
%% 例9.1 imdilate 膨胀
clc
clear
A = imread('..\Pictures\images_ch09\Fig0906(a)(broken-text).tif');
info = imfinfo('..\Pictures\images_ch09\Fig0906(a)(broken-text).tif')
B = [0 1 0
1 1 1
0 1 0];
A2 = imdilate(A, B);
A3 = imdilate(A2, B); % 二次膨胀
A4 = imdilate(A3, B); % 三次膨胀
% A2 = imdilate(B,A); % 哈哈...
imshowMy(A)
title('原始图像')
imshowMy(A2)
title('使用结构元素[B]一次膨胀后的图像')
imshowMy(A3)
title('使用结构元素[B]二次膨胀后的图像')
imshowMy(A4)
title('使用结构元素[B]三次膨胀后的图像')
imshowMy(A2-A) % 显示增加的部分
title('使用结构元素[B]一次膨胀后和原图像相比较增加的部分')
%% 例9.3 imerode
clc
clear
A = imread('..\Pictures\images_ch09\Fig0908(a)(wirebond-mask).tif');
se = strel('disk', 10);
imshowMy(A)
title('原始图像')
A2 = imerode(A, se);
imshowMy(A2)
title('使用结构元素[disk(10)]腐蚀后的图像')
se = strel('disk', 5);
A3 = imerode(A, se);
imshowMy(A3)
title('使用结构元素[disk(5)]腐蚀后的图像')
A4 = imerode(A, strel('disk', 20));
imshowMy(A4)
title('使用结构元素[disk(20)]腐蚀后的图像')
%% 例9.4.1 imopen imclose 注意当结构元素分别使用 square 和 disk 的巨大区别!!!
clc
clear
f = imread('..\Pictures\images_ch09\Fig0910(a)(shapes).tif');
% se = strel('square', 5); % 结构元素 方型
se = strel('disk', 5); % 结构元素 圆盘形
imshowMy(f) % 原始图 图1
title('原始图像')
fo = imopen(f, se); % 开 图2
imshowMy(fo)
title('使用结构元素[disk(5)]开操作后的图像')
fc = imclose(f, se); % 闭 图3
imshowMy(fc)
title('使用结构元素[disk(5)]闭操作后的图像')
foc = imclose(fo, se); % 先开再闭 图4
imshowMy(foc)
title('使用结构元素[disk(5)]先开操作再闭操作后的图像')
fco = imopen(fc, se); % 先闭再开 图5
imshowMy(fco)
title('使用结构元素[disk(5)]先闭操作再开操作后的图像')
% 先膨胀再腐蚀 图6
fse = imdilate(f, se);
figure,set(gcf,'outerposition',get(0,'screensize'))
subplot(211),imshow(fse)
title('使用结构元素[disk(5)]先膨胀后的图像')
fes = imerode(fse, se);
subplot(212),imshow(fes)
title('使用结构元素[disk(5)]先膨胀再腐蚀后的图像')
% 先腐蚀再膨胀 图7
fse = imerode(f, se);
figure, set(gcf,'outerposition',get(0,'screensize'))
subplot(211),imshow(fse)
title('使用结构元素[disk(5)]先腐蚀后的图像')
fes = imdilate(fse, se);
subplot(212),imshow(fes)
title('使用结构元素[disk(5)]先腐蚀再膨胀后的图像')
%% 例9.4.2 imopen imclose 指纹
clc
clear
f = imread('..\Pictures\images_ch09\Fig0911(a)(noisy-fingerprint).tif');
se = strel('square', 3); % 结构元素
% se = strel('disk', 2); % 结构元素 圆盘形
imshowMy(f) % 原始图
title('原始图像')
A = imerode(f, se); % 腐蚀
imshowMy(A)
title('使用结构元素[square(3)]腐蚀后的图像')
fo = imopen(f, se);
imshowMy(fo) % 开
title('使用结构元素[square(3)]开操作后的图像')
fc = imclose(f, se); % 闭
imshowMy(fc)
title('使用结构元素[square(3)]闭操作后的图像')
foc = imclose(fo, se); % 先开再闭
imshowMy(foc)
title('使用结构元素[square(3)]先开操作再闭操作后的图像')
fco = imopen(fc, se); % 先闭再开
imshowMy(fco)
title('使用结构元素[square(3)]先闭操作再开操作后的图像')
%% 例9.5 bwhitmiss 击中或击不中变换
clc
clear
f = imread('..\Pictures\images_ch09\Fig0913(a)(small-squares).tif');
imshowMy(f)
imfinfoMy(f)
title('原始图像')
B1 = strel([0 0 0;
0 1 1;
0 1 0]); % 击中:要求“击中”所有的“1”位置,不需要考虑“0”位置
B2 = strel([1 1 1;
1 0 0;
1 0 0]); % 击不中:要求“击不中”所有的“1”位置,不需要考虑“0”位置
B3 = strel([0 1 0;
1 1 1;
0 1 0]);
B4 = strel([1 0 1;
0 0 0;
0 0 0]);
B5 = strel([0 0 0;
0 1 0;
0 0 0]); % 击中
B6 = strel([1 1 1;
1 0 0;
1 0 0]); % 击不中
g = bwhitmiss(f, B1, B2);
imshowMy(g)
title('使用结构元素组[1]击中击不中变换后的图像')
g2 = bwhitmiss(f, B3, B4);
imshowMy(g2)
title('使用结构元素组[2]击中击不中变换后的图像')
g3 = bwhitmiss(f, B5, B6);
imshowMy(g3)
title('使用结构元素组[3]击中击不中变换后的图像')
%% 利用定义来实现“击中击不中”运算
clc
clear
f = imread('..\Pictures\images_ch09\Fig0913(a)(small-squares).tif');
imshowMy(f)
imfinfoMy(f)
title('原始图像')
B1 = strel([0 0 0;
0 1 1;
0 1 0]); % 击中
B2 = strel([1 1 1;
1 0 0;
1 0 0]); % 击不中
B3 = strel([0 1 0;
1 1 1;
0 1 0]);
B4 = strel([1 0 1;
0 0 0;
0 0 0]);
g = imerode(f,B1) & imerode(~f,B2);
imshowMy(g)
title('使用结构元素组[1]击中击不中变换后的图像')
%% makelut
clc
clear
f = inline('sum(x(:)) >= 3');
lut2 = makelut(f,2)
lut3 = makelut(f,3)
%% 例9.6 makelut 大笑猫之生存游戏 P267
clc
clear
lut = makelut(@conwaylaws, 3);
bw1 = [0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 1 0 0 1 0 0 0
0 0 0 1 1 1 1 0 0 0
0 0 1 0 0 0 0 1 0 0
0 0 1 0 1 1 0 1 0 0
0 0 1 0 0 0 0 1 0 0
0 0 0 1 1 1 1 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 ];
imshowMy(bw1, 'notruesize'), title('Generation 1') % 'n' == 'notruesize'
% imshowMy(bw1), title('Generation 1')
bw2 = applylut(bw1, lut);
imshowMy(bw2, 'n'), title('Generation 2')
bw3 = applylut(bw2, lut);
imshowMy(bw3, 'n'), title('Generation 3')
bw4 = applylut(bw3, lut);
imshowMy(bw4, 'n'), title('Generation 4')
bw5 = applylut(bw4, lut);
imshowMy(bw5, 'n'), title('Generation 5')
bw6 = applylut(bw5, lut);
imshowMy(bw6, 'n'), title('Generation 6')
bw7 = applylut(bw6, lut);
imshowMy(bw7, 'n'), title('Generation 7')
bw8 = applylut(bw7, lut);
imshowMy(bw8, 'n'), title('Generation 8')
temp = bw1;
for i = 2:100;
bw100 = applylut(temp, lut);
temp = bw100;
end
imshowMy(bw100, 'n'), title('Generation 100')
%% getsequence
clc
clear
se = strel('diamond', 5)
decomp = getsequence(se)
decomp(1)
decomp(2)
decomp(3)
decomp(4)
% decomp(1)*decomp(2)*decomp(3)*decomp(4) 是错误的
% rse = imdilate(imdilate(imdilate(decomp(1), decomp(2)), decomp(3)),...
% decomp(4)) 是错误的
%% endpoints
clc
clear
f = imread('..\Pictures\images_ch09\Fig0914(a)(bone-skel).tif');
imshowMy(f)
title('原始形态骨骼的图像')
g = endpoints(f);
imshowMy(g)
title('使用函数[endpoints]后得到的端点图像')
f = imread('..\Pictures\images_ch09\Fig0916(a)(bone).tif');
imshowMy(f)
title('原始骨头图像')
g = endpoints(f);
imshowMy(g)
title('使用函数[endpoints]后得到的端点图像(什么也没有)')
%% bwmorph 'remove' 'skel' 'shrink' ‘thin’
clc
clear
BW = imread('circles.png');
imshowMy(BW);
BW2 = bwmorph(BW,'remove');
imshowMy(BW2)
BW3 = bwmorph(BW,'skel',Inf);
imshowMy(BW3)
BW4 = bwmorph(BW,'shrink',Inf); % 去掉毛刺的“骨骼化”
imshowMy(BW4)
ginf = bwmorph(BW, 'thin', Inf);
imshowMy(ginf)
title('使用函数[bwmorph]细化到稳定状态后的图像')
%% P433 边界提取 bwmorph 'remove' 'skel' 'shrink' ‘thin’
clc
clear
BW = imread('..\DIP_SourceImage\images_chapter_09\Fig9.14(a).jpg');
imshowMy(BW)
title('原始图像')
BW2 = bwmorph(BW,'remove'); % 有时达不到理想的提取边界效果
imshowMy(BW2)
BW3 = bwmorph(BW,'skel',Inf);
imshowMy(BW3)
BW4 = bwmorph(BW,'shrink',Inf); % 去掉毛刺的“骨骼化”
imshowMy(BW4)
ginf = bwmorph(BW, 'thin', Inf);
imshowMy(ginf)
title('使用函数[bwmorph]细化到稳定状态后的图像')
%% bwmorph 'bridge' 'clean' 'hbreak'
clc
clear
f = imread('..\Pictures\images_ch09\Fig0911(a)(noisy-fingerprint).tif');
imshowMy(f) % 原始图
title('
没有合适的资源?快使用搜索试试~ 我知道了~
Ch-9.morphological-image-processing.rar_478ch .com_Morphological
共73个文件
jpg:38个
m:17个
tif:17个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 159 浏览量
2022-09-24
19:33:56
上传
评论
收藏 2.21MB RAR 举报
温馨提示
This file consists matlab programs implemented in morphological image processing
资源推荐
资源详情
资源评论
收起资源包目录
Ch-9.morphological-image-processing.rar (73个子文件)
Ch-9.morphological image processing
functions
endpoints.m 2KB
conwaylaws.m 906B
images
Fig0908(a)(wirebond-mask).tif 29KB
Fig0926(a)(rice).tif 65KB
Fig0917(a)(ten-objects).tif 8KB
Fig0903(a)(utk).tif 9KB
Fig0911(a)(noisy-fingerprint).tif 10KB
Fig0923(a)(aerial).tif 225KB
Fig0913(a)(small-squares).tif 9KB
Fig0922(a)(book-text).tif 227KB
Fig0906(a)(broken-text).tif 28KB
Fig0925(a)(dowels).tif 351KB
Fig0916(a)(bone).tif 19KB
Fig0903(b)(gt).tif 9KB
Fig0914(a)(bone-skel).tif 19KB
Fig0921(b)(recon-marker).tif 446KB
Fig0910(a)(shapes).tif 20KB
Fig0921(a)(recon-mask).tif 446KB
Fig0930(a)(calculator).tif 1.47MB
output
9_3_d_erosion_diskradius_20.jpg 10KB
9_3_b_erosion_10.jpg 16KB
9_12_Tophat-by-reconstruction.jpg 26KB
9_3_a_input.jpg 27KB
9_4_d_closingOf_b.jpg 10KB
9_9_image opend using disk_5.jpg 42KB
9_8_opened by reconstruction.jpg 47KB
9_9_closing of opening.jpg 36KB
9_7_input.jpg 9KB
9_10 input.jpg 18KB
9_10_result.jpg 24KB
9_9_input.jpg 42KB
9_10_Opened image showing an estimate of the background.jpg 6KB
9_7_centreOfMass.jpg 10KB
9_1_imdilate.jpg 54KB
9_5_hitOrMiss.jpg 7KB
9_8_original.jpg 136KB
9_3_c_erosion_5.jpg 18KB
9_8_border characters removed.jpg 135KB
9_1_imdilateinput.jpg 51KB
9_4_b_opening.jpg 11KB
9_10_Result of subtracting the estimated background.jpg 18KB
9_11_2.jpg 33KB
9_12_tophat.jpg 34KB
9_10_Result of thresholding the image in (d).jpg 18KB
9_11_1.jpg 31KB
9_12_opening.jpg 20KB
9_12_Opening-by-reconstruction.jpg 21KB
9_5_input.jpg 12KB
9_8_eroded_with_verticalline.jpg 22KB
9_12_Opening-by-reconstruction of (d) using a horizontal.jpg 22KB
9_8_opened_with_verticaline.jpg 29KB
9_8_holes filled.jpg 131KB
9_12_Dilation of (f) using a horizontal line. (h) Final reconstruction result.jpg 23KB
9_12_original image.jpg 36KB
9_4_closing.jpg 12KB
9_12_dilation.jpg 22KB
9_4_a_opening.jpg 12KB
examples
ex9_9.m 321B
ex9_7.asv 543B
ex9_2.m 164B
ex9_3.m 294B
ex9_7.m 532B
CH9.m 19KB
ex9_4.m 257B
ex9_4_2.m 174B
ex9_8.m 227B
ex9_12.m 588B
ex9_10.m 320B
ex9_6.m 1KB
ex9_5.m 201B
ex9_11.m 478B
ex9_bwmorph.m 369B
ex9_1.m 145B
共 73 条
- 1
资源评论
小贝德罗
- 粉丝: 68
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 解决未在远程桌面会话中捕获到鼠标,vmguest.iso软件分享给大家
- JSP+SQL基于WEB的开放性实验管理系统设计与实现(源代码+论文+开题报告+中英文献+答辩PPT).rar
- log4net配置文件!!!!!!!!!!!!!!!!!
- 河南统计面板数据集(2010-2022年).xlsx
- OrcaleDBHelper帮助类!!!!!!!!!!!!
- log4net帮助类,用来写日志!!!!!!!!!!!!!
- Windows10时间同步源
- 信呼OA系统2.1.7版源码
- 3122080306 邹子轩 实验报告二.docx
- 基于STM32 NUCLEO板设计彩色LED照明灯(纯cubeMX开发)(大赛作品,文档完整,可直接运行)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功