形态学图像处理
1、二值膨胀
膨胀图像的函数:
imdilate
J=imdilate(I,SE)
分别采用square和disk结构膨胀图像
B1=imread('D:\zs.jpg');
I=rgb2gray(B1);
se1=strel('square',8)
I1=imdilate(I,se1);
se2=strel('disk',10)
I2=imdilate(I,se2);
subplot(1,3,1)
imshow(I)
subplot(1,3,2),imshow(I1)
subplot(1,3,3),imshow(I2)
imdilate(I,SE)
SE的值越大,膨胀效果越明显。
实验结果有两种:
①不用roberts算子提取边缘时:
像不像化妆与卸妆对比hhhh
②用robert算子提取边缘时:
效果是不是完全不一样啦!
知世我对不起你。
2、灰度腐蚀
①不提取边缘
(给知世画个大浓妆!!)
B1=imread('D:\zs.jpg');
I=rgb2gray(B1);
%I=edge(B2,'roberts');
se1=strel('square',4)
I1=imerode(I,se1);
se2=strel('square',7)
I2=imerode(I,se2);
subplot(1,3,1),imshow(I)
subplot(1,3,2),imshow(I1)
subplot(1,3,3),imshow(I2)
②提取边缘
B1=imread('D:\zs.jpg');
B2=rgb2gray(B1);
I=edge(B2,'roberts');
se1=strel('square',1)
I1=imerode(I,se1);
se2=strel('square',2)
I2=imerode(I,se2);
subplot(1,3,1),imshow(I)
subplot(1,3,2),imshow(I1)
subplot(1,3,3),imshow(I2)
知世轮廓一腐蚀就消失了。
3、用imfill函数填充图像
(仍然以知世为例)
B1=imread('D:\zs.jpg');
B2=rgb2gray(B1);
I=edge(B2,'roberts');
J=imfill(I,'holes');
subplot(1,2,1),imshow(I);
subplot(1,2,2),imshow(J);
实验结果