MATLAB之图像形态学

BW1 = imread(‘circbw.tif’);
BW2 = bwperim(BW1,8);
subplot(121), imshow(BW1) ; title(‘原始图像’);
subplot(122), imshow(BW2) ; title(‘边缘检测后的图像’);
在这里插入图片描述
bw = [0 0 0 0 0 0
0 0 1 1 0 0
0 1 1 1 1 0
0 1 1 1 1 0
0 0 1 1 0 0
0 0 1 0 0 0];
interval = [0 -1 -1
1 1 -1
0 1 0];
bw2 = bwhitmiss(bw,interval)%击中击不中操作
bw2 =

6×6 logical 数组

0 0 0 0 0 0
0 0 0 1 0 0
0 0 0 0 1 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
I = imread(‘rice.png’);
subplot(121), imshow(I) ; title(‘原始图像’);
se = strel(‘disk’,12); %生成圆盘形状的结构元素
J = imtophat(I,se); %使用top-hat对图像进行滤波
subplot(122), imshow(J) ; title(‘top-hat滤波后的图像’);
在这里插入图片描述
I = imread(‘pout.tif’);
subplot(121), imshow(I) ; title(‘原图像’);
se = strel(‘disk’,3);%生成圆形的结构元素
I1=imtophat(I,se);%top-hat滤波
I2=imadd(I,I1);%原图像加上top-hat滤波后的图像
I3=imbothat(I,se);%bottom-hat滤波
J = imsubtract(I2, I3);%再减去bottom-hat滤波后的图像
subplot(122), imshow(J) ; title(‘增强后的图像’);
在这里插入图片描述

猜你喜欢

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