写成正规代码形式I=imread('C:\Users\hp\Desktop\yy.PNG');% ?提取图像 subplot(2,3,1), imshow(I); title('original image'); I=rgb2gray(I);%将彩色图转换灰度图 BW1=edge(I,'sobel'); %用SOBEL算子进行边缘检测 BW2=edge(I,'roberts');%用Roberts算子进行边缘检测 BW3=edge(I,'prewitt'); %用prewitt算子进行边缘检测 BW4=edge(I,'log'); %用log算子进行边缘检测 BW5=edge(I,'canny'); %用canny算子进行边缘检测 subplot(2,3,2), imshow(BW1); title('sobel edge check'); subplot(2,3,3), imshow(BW2); title('roberts edge check'); subplot(2,3,4), imshow(BW3); title('prewitt edge check'); subplot(2,3,5), imshow(BW4); title('Laplacian edge check'); subplot(2,3,6), imshow(BW5); title('canny edge check');
时间: 2024-01-04 11:04:11 浏览: 348
```matlab
I = imread('C:\Users\hp\Desktop\yy.PNG'); % 提取图像
subplot(2,3,1), imshow(I); title('original image');
I = rgb2gray(I); % 将彩色图转换灰度图
BW1 = edge(I,'sobel'); % 用SOBEL算子进行边缘检测
BW2 = edge(I,'roberts'); % 用Roberts算子进行边缘检测
BW3 = edge(I,'prewitt'); % 用prewitt算子进行边缘检测
BW4 = edge(I,'log'); % 用log算子进行边缘检测
BW5 = edge(I,'canny'); % 用canny算子进行边缘检测
subplot(2,3,2), imshow(BW1); title('sobel edge check');
subplot(2,3,3), imshow(BW2); title('roberts edge check');
subplot(2,3,4), imshow(BW3); title('prewitt edge check');
subplot(2,3,5), imshow(BW4); title('Laplacian edge check');
subplot(2,3,6), imshow(BW5); title('canny edge check');
```
这是将原来的代码格式化后的正规形式。需要注意的是,Matlab中的语句一般以分号结尾,但这里的subplot()函数是一个例外,需要直接跟在语句后面,因为它是一个绘图函数,需要连续执行多条命令。
阅读全文
相关推荐


















