clc;
I=imread('test.jpg');
I=rgb2gray(I); %灰度化
p=fspecial('sobel'); %构造sobel算子
BW1=imfilter(I,p); %使用sobel算子进行滤波
imshow(BW1); %显示图像
figure;
BW2=edge(I,'sobel'); %使用sobel进行边缘检测
I=imread('test.jpg');
I=rgb2gray(I); %灰度化
p=fspecial('sobel'); %构造sobel算子
BW1=imfilter(I,p); %使用sobel算子进行滤波
imshow(BW1); %显示图像
figure;
BW2=edge(I,'sobel'); %使用sobel进行边缘检测
imshow(BW2);
总结:我们把经过差分算子滤波过的图像通过阈值取舍而得到边缘,而锐化没有阈值取舍这个过程.