以灰度图像rice.png为例,利用Matlab图像处理工具箱中的edge函数,分别使用Roberts 算子、Sobel算子、Prewitt 算子对其进行边缘检测。
I=imread('rice.png');
[BW1,thresh1]=edge(I,'roberts');
[BW2,thresh2]=edge(I,'sobel');
[BW3,thresh3]=edge(I,'prewitt');
subplot(2,2,1);
imshow(I);
subplot(2,2,2);
imshow(BW1);
subplot(2,2,3);
imshow(BW2);
subplot(2,2,4);
imshow(BW3);