MATLAB图像形态学二

originalBW = imread(‘circles.png’);
se = strel(‘disk’,11);%生成圆盘形的结构元素
erodedBW = imerode(originalBW,se);%对图像进行腐蚀
subplot(121), imshow(originalBW), title(‘原始图像’);
subplot(122), imshow(erodedBW); title(‘腐蚀后的图像’);
在这里插入图片描述
I = imread(‘cameraman.tif’);
se = strel(‘ball’,5,5);%生成球形的结构元素
I2 = imerode(I,se);%对图像进行腐蚀
subplot(121), imshow(I), title(‘原始图像’)
subplot(122), imshow(I2), title(‘腐蚀后的图像’)
在这里插入图片描述
BW1 = imread(‘circbw.tif’);%读取图像
subplot(131), imshow(BW1); title(‘原始图像’);
SE = strel(‘rectangle’,[40 30]);%生成矩形结构元素
BW2 = imerode(BW1,SE);%对图像进行腐蚀
subplot(132), imshow(BW2); title(‘腐蚀后的图像’);
BW3 = imdilate(BW2,SE);%对图像进行膨胀
subplot(133), imshow(BW3); title(‘先腐蚀后膨胀的图像’);
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_38127487/article/details/115254250