岭南师范学院
课程名称数字图像处理
实验序号实验5
实验名称图像分割和边缘检测
实验地点综B207
2017年10 月14 日
四、实验过程(实验步骤、记录、数据、分析)
1.基于一阶导数的边缘算子
a=imread('y.jpg');
f=rgb2gray(a);
subplot(2,2,1),imshow(f),title('原始图像');
[g1 , t1]=edge(f,'roberts',[ ], 'horizontal'); subplot(2,2,2), imshow(g1),title('Roberts');
[g2, t2]=edge(f, 'sobel',[ ], 'horizontal'); subplot(2,2,3), imshow(g2),title('Sobel');
[g3, t3]=edge(f, 'prewitt',[ ], 'horizontal'); subplot(2,2,4), imshow(g3),title('Prewitt');
从图像结果来看,'Roberts'的边缘检测范围更加大
2、基于二阶导数的边缘算子:应用LOG算子检测边缘
a=imread('y.jpg');
f=rgb2gray(a);
subplot(1,2,1),imshow(f),title('原始图像');
[g , t]=edge(f, 'log');
subplot(1,2,2),imshow(g),title('log');
3、基于约束条件的最优化检测边缘算子:应用Canny算子检测边缘a=imread('y.jpg');
f=rgb2gray(a);
subplot(1,2,1),imshow(f),title('原始图像');
[g , t]=edge(f,'canny');
subplot(1,2,2),imshow(g),title('Canny');。