梯度算子检测边缘
用 MATLAB 实现如下:
I=imread('xian.bmp');
subplot(2,3,1);
imshow(I);
title('原始图像');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
I1=im2bw(I);
subplot(2,3,2);
imshow(I1);
title('二值图像');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
I2=edge(I1,'roberts');
figure;
subplot(2,3,3);
imshow(I2);
title('roberts 算子分割结果');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
I3=edge(I1,'sobel');
subplot(2,3,4);
imshow(I3);
title('sobel 算子分割结果');
axis([50,250,50,200]);
grid on; %显示网格线
axis on; %显示坐标系
I4=edge(I1,'Prewitt');
subplot(2,3,5);
imshow(I4);
title('Prewitt 算子分割结果');
axis([50,250,50,200]);
评论0