%erode 腐蚀
F=[0 1 0 1 0 0;
0 1 1 0 1 0;
0 0 1 0 0 0;
0 0 1 1 0 0;
0 0 0 0 0 0];
S1=[1,0;1,1]; %腐蚀的核
IMG=imread('EXP5.tif');
[row,col]=size(IMG);
figure,imshow(IMG);
for i=1:row
for j=1:col
if(IMG(i,j)>100)
IMG1(i,j)=1;
else
IMG1(i,j)=0;
end
end
end
F=IMG1;
for i=1:row-1
for j=1:col-1
if(F(i,j)&&F(i+1,j)&&F(i+1,j+1)) %若S中为1的位置全为1则为1
F(i,j)=1; %正向判断1
else
F(i,j)=0;
end
end
end
figure,imshow(F);
F=[0 1 0 1 0 0;
0 1 1 0 1 0;
0 0 1 0 0 0;
0 0 1 1 0 0;
0 0 0 0 0 0];
S1=[1,0;1,1]; %腐蚀的核
IMG=imread('EXP5.tif');
[row,col]=size(IMG);
figure,imshow(IMG);
for i=1:row
for j=1:col
if(IMG(i,j)>100)
IMG1(i,j)=1;
else
IMG1(i,j)=0;
end
end
end
F=IMG1;
for i=1:row-1
for j=1:col-1
if(F(i,j)&&F(i+1,j)&&F(i+1,j+1)) %若S中为1的位置全为1则为1
F(i,j)=1; %正向判断1
else
F(i,j)=0;
end
end
end
figure,imshow(F);