利用canny算子 LOG算子来检测加高斯噪声的图像。 步骤: (5)读取和显示rice.png和cameraman.tif; (6)转换为双精度型; (7)添加高斯噪声 J=imnoise(I,‘gussian’,0,0.01) (8)采用edge()函数来进行边缘检测; (9)在同一个figure窗口中,显示原图、加噪图像和边缘图像; (10)同一图像用不同的算子,比较不同的算子不同的效果,并做好分析记录;按要求写一段matlab代码
时间: 2023-06-24 10:03:37 浏览: 177
以下是实现上述步骤的 MATLAB 代码:
```matlab
% 读取和显示rice.png和cameraman.tif
rice = imread('rice.png');
cameraman = imread('cameraman.tif');
figure;
subplot(2,2,1);
imshow(rice);
title('Original Rice Image');
subplot(2,2,2);
imshow(cameraman);
title('Original Cameraman Image');
% 转换为双精度型
rice = im2double(rice);
cameraman = im2double(cameraman);
% 添加高斯噪声
J_rice = imnoise(rice, 'gaussian', 0, 0.01);
J_cameraman = imnoise(cameraman, 'gaussian', 0, 0.01);
subplot(2,2,3);
imshow(J_rice);
title('Rice Image with Gaussian Noise');
subplot(2,2,4);
imshow(J_cameraman);
title('Cameraman Image with Gaussian Noise');
% 采用edge()函数来进行边缘检测
% 使用Canny算子
rice_edge_canny = edge(J_rice, 'canny');
cameraman_edge_canny = edge(J_cameraman, 'canny');
figure;
subplot(2,2,1);
imshow(rice_edge_canny);
title('Rice Edge Detection using Canny Operator');
subplot(2,2,2);
imshow(cameraman_edge_canny);
title('Cameraman Edge Detection using Canny Operator');
% 使用LOG算子
rice_edge_log = edge(J_rice, 'log');
cameraman_edge_log = edge(J_cameraman, 'log');
subplot(2,2,3);
imshow(rice_edge_log);
title('Rice Edge Detection using LOG Operator');
subplot(2,2,4);
imshow(cameraman_edge_log);
title('Cameraman Edge Detection using LOG Operator');
```
在本代码中,我们首先读取和显示了原始的rice.png和cameraman.tif图像。然后,我们将它们转换为双精度型,并添加高斯噪声。接着,我们使用edge()函数分别对两张图像进行边缘检测,使用Canny算子和LOG算子。最后,我们在不同的subplot中显示原始图像、加噪图像和边缘图像,并比较不同算子的效果。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044947.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)