clear,clc
h=imread('ceshi2.bmp')
i=im2bw(h)
i1i=187
i1j=192
for ai=181:193
for aj=186:198
if(sqrt(double(ai-i1i)^2+double(aj-i1j)^2)<=5)
end
end
end
figure,imshow(i)
i1=i
for i1i=6:205%用B腐蚀A
for i1j=6:205
flag=0
if(i1i>=181&&i1i<=193&&i1j>=186&&i1j<=198)
continue
else
if(i(i1i,i1j)==1)
for ai=i1i-5:i1i+5
for aj=i1j-5:i1j+5
if(i1(ai,aj)==0&&sqrt(double((ai-i1i)^2+(aj-i1j)^2))<=5)
i(i1i,i1j)=0
flag=1
break
end
end
if(flag==1)
break
end
end
end
end
end
end
figure,imshow(i)
%在上面C的图像上用B进行膨胀
i2=i
for i1i=6:205%用B膨胀C
for i1j=6:205
flag=0
if(i1i>=175&&i1i<=199&&i1j>=180&&i1j<=204)
continue
else
for ai=i1i-5:i1i+5
for aj=i1j-5:i1j+5
辩胡 if(i2(ai,aj)==1&&sqrt(double((ai-i1i)^2+(aj-i1j)^2))<=5)
i(i1i,i1j)=1
flag=1
break
end
end
if(flag==1)
break
end
end
end
end
end
figure,imshow(i)
%在上面D的图像上用B进行膨胀
i2=i
for i1i=6:205%用B膨胀D
for i1j=6:205
flag=0
if(i1i>=175&&i1i<=199&&i1j>=180&&i1j<=204)
continue
else
for ai=i1i-5:i1i+5
for aj=i1j-5:i1j+5
if(i2(ai,aj)==1&&sqrt(double((ai-i1i)^2+(aj-i1j)^2))<=5)
i(i1i,i1j)=1
flag=1
break
end
end
if(flag==1)
break
扮灶春end
end
end
end
end
figure,imshow(i)
%在上面E的图像上用B进行腐蚀
i1=i
for i1i=6:205%用B腐蚀E
for i1j=6:205
flag=0
if(i1i>=181&&i1i<=193&&i1j>=186&&i1j<=198)
continue
else
if(i(i1i,i1j)==1)
for ai=i1i-5:i1i+5
for aj=i1j-5:i1j+5
if(i1(ai,aj)==0&&sqrt(double((ai-i1i)^2+(aj-i1j)^2))<=5)
i(i1i,i1j)=0
flag=1
break
厅耐 end
end
if(flag==1)
break
end
end
end
end
end
end
figure,imshow(i)
1、选取函数为f(x)=-|x-6|+5在[1,11]上的图像,画出函数图像。
2、使用strel构建平坦的结构元素,如图。
3、使用平坦的结构元素进睁销行灰度膨胀,设置y轴范围为[0, 8]如指答图。
4、构建高度为[1 1 1]的非平坦结构元素。显示的结果和平坦元素相同,但实际结构不同。悉逗游
5、使用非平坦的结构元素进行灰度膨胀,并画图即可。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)