形态学处理 - 图文(11)
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字,全部文档内容请下载后查看。喜欢就下载吧 ……
相关推荐:
- [学前教育]MC9S12XS256RMV1 xs128芯片手册4
- [学前教育]安东尼语录经典语录
- [学前教育]e级gps控制测量技术设计书
- [学前教育]苏教版2022-2022学年八年级下学期期末
- [学前教育]装修公司推广 营销
- [学前教育]家政服务合同(完整版)
- [学前教育]湖北省2016届高三联考语文试题
- [学前教育]爱立信无涯学习系统LTE题库1-LTE基础知
- [学前教育]揭秘大众柴油车作弊软件原理
- [学前教育]人才流失原因及对策分析
- [学前教育]房屋建筑施工工程劳务分包合同
- [学前教育]国际贸易实务试卷A卷09.6
- [学前教育]校园废品回收活动计划方案书范文格
- [学前教育]电大成本会计试题及答案
- [学前教育]大学物理实验 华南理工出版社 绪论答案
- [学前教育]爱丁堡产后抑郁量表
- [学前教育]液压冲击的危害、产生原因与防止方法(
- [学前教育]学生工作总结高一学生期中考试总结_020
- [学前教育]人民医院医疗废物管理规章制度大全
- [学前教育]阳光维生素的巨大抗癌潜能阅读题答案.d
- 马云在云锋基金江苏论坛闭幕式的发言
- 试论小学体育教育中的心理健康教育-教
- 语文A版一年级下册《语文乐园一》教学
- 2021四川大学物理化学考研真题经验参考
- [人教A版]2015-2016学年高中数学 第二
- 终端网点销售返利协议书
- 江苏省2015年眼科学主治医师青光眼考试
- 2017年部编人教版八年级语文上册教案
- 十一中学七年级英语上册Unit7Howmuchar
- 以赛促教的创新性实验教学机制建设实践
- 平凉市崆峒区2015七年级下生物期末试题
- 琶洲(地块五)A、B塔楼1、2#塔吊基础
- 一级医院工作制度与人员岗位职责
- 2018北京西城区高三二模理科数学试题及
- 炒股密码线技术 - 图文
- 职高学生生涯发展辅导教案
- 语文人教版四年级上册8 世界地图引出的
- 最新最新人教版二年级上册全册数学教案
- 2017高考英语全国2卷精彩试题(有问题
- 普通心理学笔记




