matlabrobert锐化_matlab梯度法中5种图像锐化方法分别对一幅图像实现锐化。
时间: 2023-08-23 18:39:32 浏览: 79
好的,您可以使用以下 Matlab 代码实现对一幅图像的五种锐化方法:
```matlab
% 读入图像
img = imread('example.jpg');
% 1. Laplacian锐化
laplacian_filter = fspecial('laplacian', 0.5);
img_laplacian = imfilter(img, laplacian_filter);
img_laplacian = imsubtract(img, img_laplacian);
% 2. Unsharp Masking锐化
unsharp_mask_filter = fspecial('unsharp');
img_unsharp_mask = imfilter(img, unsharp_mask_filter);
img_unsharp_mask = imsubtract(img, img_unsharp_mask);
% 3. High-boost锐化
highboost_filter = fspecial('unsharp', 2);
img_highboost = imfilter(img, highboost_filter);
img_highboost = imsubtract(img, img_highboost);
% 4. Sobel锐化
img_sobel = imgradient(img, 'sobel');
% 5. Prewitt锐化
img_prewitt = imgradient(img, 'prewitt');
% 显示结果
subplot(2, 3, 1);
imshow(img);
title('原始图像');
subplot(2, 3, 2);
imshow(img_laplacian);
title('Laplacian锐化');
subplot(2, 3, 3);
imshow(img_unsharp_mask);
title('Unsharp Masking锐化');
subplot(2, 3, 4);
imshow(img_highboost);
title('High-boost锐化');
subplot(2, 3, 5);
imshow(img_sobel);
title('Sobel锐化');
subplot(2, 3, 6);
imshow(img_prewitt);
title('Prewitt锐化');
```
其中,`example.jpg` 是您要进行锐化的图像。这个代码中使用了 `fspecial` 函数创建了三个不同的滤波器来实现 Laplacian、Unsharp Masking 和 High-boost 锐化。最后还使用了 `imgradient` 函数来分别实现 Sobel 和 Prewitt 锐化。在最后使用 `subplot` 函数将原始图像和五种锐化方法的结果显示在同一张图中。