教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 学前教育 >

形态学处理 - 图文(12)

来源:网络收集 时间:2026-09-09
导读: %所以它们经常组合起来一起进行平滑图像并去除噪声 clc clear f=imread('.\\images\\dipum_images_ch09\\Fig0925(a)(dowels).tif'); subplot(221),imshow(f); title('木钉图像原图'); se=strel('disk',5);%disk其实

%所以它们经常组合起来一起进行平滑图像并去除噪声 clc clear

f=imread('.\\images\\dipum_images_ch09\\Fig0925(a)(dowels).tif'); subplot(221),imshow(f); title('木钉图像原图');

se=strel('disk',5);%disk其实就是一个八边形 fo=imopen(f,se);%经过开运算 subplot(222),imshow(f);

title('使用半径5的disk开运算后的图像');

foc=imclose(fo,se);

subplot(223),imshow(foc); title('先开后闭的图像');

fasf=f; for i=2:5

se=strel('disk',i);

fasf=imclose(imopen(fasf,se),se); end

subplot(224),imshow(fasf);

title('使用开闭交替滤波后图像');

390%使用开运算和闭运算做形态学平滑结果如下:

%% 颗粒分析 clc clear

f=imread('.\\images\\dipum_images_ch09\\Fig0925(a)(dowels).tif');

sumpixels=zeros(1,36); for k=0:35

se=strel('disk',k); fo=imopen(f,se);

sumpixels(k+1)=sum(fo(:)); end

%可以看到,连续开运算之间的表面积会减少 plot(0:35,sumpixels),xlabel('k'),ylabel('surface area'); title('表面积和结构元素半径之间的关系'); 407%其运算结果如下:

figure,plot(-diff(sumpixels));%diff()函数为差分或者近似倒数,即相邻2个之间的差值 xlabel('k'),ylabel('surface area reduction');

title('减少的表面积和结构元素半径之间的关系'); 412%其运算结果如下:

%% 使用重构删除复杂图像的背景 clc clear

f=imread('.\\images\\dipum_images_ch09\\Fig0930(a)(calculator).tif'); subplot(221),imshow(f); title('灰度级重构原图像');

f_obr=imreconstruct(imerode(f,ones(1,71)),f); subplot(222),imshow(f_obr); title('经开运算重构图');

f_o=imopen(f,ones(1,71)); subplot(223),imshow(f_o); title('经开运算后图');

f_thr=imsubtract(f,f_obr); subplot(224),imshow(f_thr); title('顶帽运算重构图')

432%使用重构删除复杂图像的背景1:

f_th=imsubtract(f,f_o)

figure,subplot(221),imshow(f_th); title('经顶帽运算图');

g_obr=imreconstruct(imerode(f_thr,ones(1,11)),f_thr); subplot(222),imshow(g_obr);

title('用水平线对f_thr经开运算后重构图');

g_obrd=imdilate(g_obr,ones(1,2)); subplot(223),imshow(g_obrd);

title('使用水平线对上图进行膨胀');

f2=imreconstruct(min(g_obrd,f_thr),f_thr); subplot(224),imshow(f2); title('最后的重构结果');

449%使用重构删除复杂图像的背景2:

形态学处理 - 图文(12).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/597156.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)