MATLAB边缘检测

发布时间 2023-12-20 16:58:27作者: DOVI666

使用如下命令可生成不同边沿检测算法下的图案:

 1 %对同一副图像分别使用6种边缘检测算法进行处理
 2 
 3  4 A = imread ('chepai.jpg');      %读入图像chepai.jpg,赋给变量A
 5 A = rgb2gray(A);
 6 
 7 bw1 = edge(A,'sobel');
 8 bw2 = edge(A,'prewitt');
 9 bw3 = edge(A,'roberts');
10 bw4 = edge(A,'log');
11 bw5 = edge(A,'canny');
12 
13 subplot(2,3,1);imshow(A);title('原图');
14 subplot(2,3,2);imshow(bw3);title('roberts');
15 subplot(2,3,3);imshow(bw1);title('sobel');
16 subplot(2,3,4);imshow(bw2);title('prewitt');
17 subplot(2,3,5);imshow(bw4);title('log');
18 subplot(2,3,6);imshow(bw5);title('canny');

建议使用m脚本文件,一次性搞定。

 

资料来源:博客园——咸鱼IC(matlab数字图像处理 入门基础 - 咸鱼IC - 博客园 (cnblogs.com)