%% 学习目标: sobel算子图像边缘检测
I=imread('rice.png');
figure(1)
subplot(1,2,1);
imshow(I)
title('原图')
subplot(1,2,2);
imhist(I) %显示图像的直方图
title('原图直方图')
I0=edge(I,'sobel'); %自动选择阈值
I1=edge(I,'sobel',0.08); %指定阈值0.08
I2=edge(I,'sobel',0.02); %指定阈值0.02
figure(2)
subplot(2,2,1);
imshow(I0)
title('默认阈值')
subplot(2,2,3);imshow(I1)
title('阈值=0.08')
subplot(2,2,4);imshow(I2)
title('阈值=0.02')
%% 大仙QQ:1960009019
%% 在线教育微信公众号:大仙一品堂