数字图像处理腐蚀与膨胀小程序.doc

数字图像处理腐蚀与膨胀小程序.doc

ID:51845349

大小:28.50 KB

页数:4页

时间:2020-03-16

数字图像处理腐蚀与膨胀小程序.doc_第1页
数字图像处理腐蚀与膨胀小程序.doc_第2页
数字图像处理腐蚀与膨胀小程序.doc_第3页
数字图像处理腐蚀与膨胀小程序.doc_第4页
资源描述:

《数字图像处理腐蚀与膨胀小程序.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、%%%%%%%%%%%%%%%%下面为用于处理的样本‘圆’%%%%%%%%%%%%%%%%%%%%%%%%%R=8;%%半径RS=zeros(2*R);forx1=-R:R-1;fory1=-R:R-1;ifround(sqrt(x1^2+y1^2))<=R%%圆心在原点的圆的表达函数%%对圆心在原点的圆进行平移,使x,y都为非负数x=R+x1+1;y=R+y1+1;S(x,y)=1;endendendfigure(1),imshow(S);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

2、%%%%%%%%%%%%%%%%%%%%%下面为要处理的图形%%%%%%%%%%%%%%%%%%%%%%%%%W=256;L=512;%%定义边界X=zeros(W,L);fori=1:128forj=1:256ifi<=15

3、i>=114ifj<103

4、j>153X(i+W/4,j+L/4)=1;endelseif(i>15&i<=56)

5、(i>=72&i<114)if(j>50&j<103)

6、j>153X(i+W/4,j+L/4)=1;endelseifi>56&i<72ifj>50&j<206X(i+W/4,j+L/4)=1;endendendendendendfig

7、ure(2),imshow(X);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%下面用S对X进行腐蚀操作%%%%%%%%%%%%%%%%%%%%%%%%X1=zeros(W,L);%X1用于存放处理后的图像M=zeros(2*R);form=0:W-2*Rforn=0:L-2*R%%下面用S对X区域进行‘与’操作%%fori=1:2*Rforj=1:2*RM(i,j)=X(i+m,j+n)&S(i,j);endendifM==S%%判断S是否处于X

8、中,等则在S中X1(m+R,n+R)=1;endM=zeros(2*R);endendfigure(3),imshow(X1);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%下面用S对X1进行膨胀操作%%%%%%%%%%%%%%%%%%%%%%%%%%X2=zeros(W,L);%X2用于存放处理后的图像cnt=0;form=0:W-2*Rforn=0:L-2*R%%下面用S对X区域进行‘与’操作%%fori=1:2*Rforj=1:2*RifX1(i+m,

9、j+n)&S(i,j)==1%%判断S是否与X相交cnt=1;break;endendifcnt==1%%判断是否是由于cnt=1而跳出循环break;endendifcnt==1%%判断是否是由于cnt=1而跳出循环X2(m+R,n+R)=1;cnt=0;%%将cnt的值置0endendendfigure(4),imshow(X2);(S)(X)(X1)(X2)

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。