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

形态学处理 - 图文(11)

来源:网络收集 时间:2026-09-09
导读: title('击中或不击中原始图像'); 148%击中或不击中原始图像显示结果如下: B1=strel([0 0 0;0 1 1;0 1 0]);%击中:要求击中所有1的位置 B2=strel([1 1 1;1 0 0;1 0 0]);%击不中,要求击不中所有1的位置 B3=strel([0

title('击中或不击中原始图像');

148%击中或不击中原始图像显示结果如下:

B1=strel([0 0 0;0 1 1;0 1 0]);%击中:要求击中所有1的位置 B2=strel([1 1 1;1 0 0;1 0 0]);%击不中,要求击不中所有1的位置 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=imerode(f,B1)&imerode(~f,B2)%利用定义来实现击中或击不中 figure,subplot(221),imshow(g);

title('定义实现组1击中击不中图像');

g1=bwhitmiss(f,B1,B2); subplot(222),imshow(g1);

title('结构数组1击中击不中后的图像');

g2=bwhitmiss(f,B3,B4); subplot(223),imshow(g2);

title('结构数组2击中击不中的图像');

g3=bwhitmiss(f,B5,B6); subplot(224),imshow(g3);

title('结构数组3击中击不中的图像'); 172%击中击不中变换后图像如下:

%%makelut clc clear

f=inline('sum(x(:))>=3');%inline是用来定义局部函数的

lut2=makelut(f,2)%为函数f构造一个接收2*2矩阵的查找表 lut3=makelut(f,3)

%% Conway生命游戏 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 1 0 0 1 0 0 0 0 0 1 1 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 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 ]; subplot(221),imshow(bw1,'InitialMagnification','fit'); title('Generation 1');

bw2=applylut(bw1,lut);

subplot(222),imshow(bw2,'InitialMagnification','fit'), title('Generation 2');

bw3=applylut(bw2,lut);

subplot(223),imshow(bw3,'InitialMagnification','fit'); title('Generation 3');

temp=bw1; for i=2:100

bw100=applylut(temp,lut); temp=bw100; end

subplot(224),imshow(bw100,'InitialMagnification','fit') title('Generation 100');

214%显示Generation结果如下:

%% getsequence clc clear

se=strel('diamond',5)

decomp=getsequence(se)%getsequence函数为得到分解的strel序列 decomp(1) decomp(2)

%% endpoints clc clear

f1=imread('.\\images\\dipum_images_ch09\\Fig0914(a)(bone-skel).tif'); subplot(121),imshow(f1); title('原始形态骨架图像');

g1=endpoints(f1);

%set(gcf,'outerposition',get(0,'screensize'));%运行完后自动生成最大的窗口 subplot(122),imshow(g1);

title('骨架图像的端点图像'); %骨架头像端点检测头像如下:

f2=imread('.\\images\\dipum_images_ch09\\Fig0916(a)(bone).tif'); figure,subplot(121),imshow(f2); title('原始骨头图像');

g2=endpoints(f2);

subplot(122),imshow(g2);

title('骨头图像端点头像');%结果是没有端点 245%骨头头像端点检测图像如下:

%% bwmorph组合常见形态学之细化 clc clear

f=imread('.\\images\\dipum_images_ch09\\Fig0911(a)(noisy-fingerprint).tif'); subplot(221),imshow(f); title('指纹图像细化原图');

g1=bwmorph(f,'thin',1); subplot(222),imshow(g1); title('指纹图像细化原图');

g2=bwmorph(f,'thin',2); subplot(223),imshow(g2); title('指纹图像细化原图');

g3=bwmorph(f,'thin',Inf); subplot(224),imshow(g3); title('指纹图像细化原图');

265%指纹图像细化过程显示如下:

%% bwmorph组合常见形态学之骨骼化 clc clear

f=imread('.\\images\\dipum_images_ch09\\Fig0911(a)(noisy-fingerprint).tif'); subplot(131),imshow(f);

title('指纹图像骨骼化原图');

fs=bwmorph(f,'skel',Inf); subplot(132),imshow(fs); title('指纹图像骨骼化');

for k=1:5

fs=fs&~endpoints(fs); end

subplot(133),imshow(fs);

title('指纹图像修剪后骨骼话'); 283%指纹图像骨骼化过程显示:

%% 使用函数bwlabel标注连通分量 clc clear

f=imread('.\\images\\dipum_images_ch09\\Fig0917(a)(ten-objects).tif'); imshow(f),title('标注连通分量原始图像'); 290%其结果显示如下:

[L,n]=bwlabel(f);%L为标记矩阵,n为找到连接分量的总数 [r,c]=find(L==3);%返回第3个对象所有像素的行索引和列索引

rbar=mean(r); cbar=mean(c);

figure,imshow(f)

hold on%保持当前图像使其不被刷新 for k=1:n

[r,c]=find(L==k); rbar=mean(r); cbar=mean(c);

plot(cbar,rbar,'Marker','o','MarkerEdgeColor','k',...

'MarkerFaceColor','k','MarkerSize',10);%这个plot函数用法不是很熟悉 plot(cbar,rbar,'Marker','*','MarkerFaceColor','w');%其中的marker为标记 end

title('标记所有对象质心后的图像');

%% 由重构做开运算 clc clear

f=imread('.\\images\\dipum_images_ch09\\Fig0922(a)(book-text).tif'); subplot(321),imshow(f); title('重构原始图像');

fe=imerode(f,ones(51,1));%竖线腐蚀 subplot(322),imshow(fe);

title('使用竖线腐蚀后的结果');

fo=imopen(f,ones(51,1));%竖线做开运算 subplot(323),imshow(fo);

title('使用竖线做开运算结果');

fobr=imreconstruct(fe,f);t做标记 subplot(324),imshow(fobr); title('使用竖线做重构开运算');

ff=imfill(f,'holes');%对f进行孔洞填充 subplot(325),imshow(ff);

title('对f填充孔洞后的图像');

fc=imclearborder(f,8);%清除边界,2维8邻接 subplot(326),imshow(fc);

title('对f清除边界后的图像'); 336%图像重构过程显示如下:

%% 使用顶帽变换和底帽变换 clc clear

f=imread('.\\images\\dipum_images_ch09\\Fig0926(a)(rice).tif'); subplot(221),imshow(f);

title('顶帽底帽变换原始图像');

se=strel('disk',10);%产生结构元素

%顶帽变换是指原始图像减去其开运算的图像

%而开运算可用于补偿不均匀的背景亮度,所以用一个大的结构元素做开运算后

%然后用原图像减去这个开运算,就得到了背景均衡的图像,这也叫做是图像的顶帽运算 f1=imtophat(f,se);%使用顶帽变换 subplot(222),imshow(f1);

title('使用顶帽变换后的图像');

%底帽变换是原始图像减去其闭运算后的图像

f2=imboth …… 此处隐藏:2637字,全部文档内容请下载后查看。喜欢就下载吧 ……

形态学处理 - 图文(11).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)