MATLAB分布使用deconvreg、deconvwnr和deconvblind复原图像的代码
时间: 2023-12-07 12:05:38 浏览: 400
好的,下面是使用MATLAB中的deconvreg、deconvwnr和deconvblind函数对图像进行去卷积处理的示例代码:
1. deconvreg函数示例代码:
```matlab
% 读取原始图像
img = imread('lena.png');
% 生成模糊核
PSF = fspecial('motion', 21, 11);
% 生成模糊图像
blurred = imfilter(img, PSF, 'conv', 'circular');
% 使用deconvreg函数进行图像复原
restored = deconvreg(blurred, PSF, 0.01);
% 显示图像
subplot(1, 2, 1);
imshow(blurred);
title('Blurry Image');
subplot(1, 2, 2);
imshow(restored);
title('Restored Image');
```
2. deconvwnr函数示例代码:
```matlab
% 读取原始图像
img = imread('lena.png');
% 生成模糊核
PSF = fspecial('motion', 21, 11);
% 生成模糊图像
blurred = imfilter(img, PSF, 'conv', 'circular');
% 生成噪声图像
noise_var = 0.0001;
noise = noise_var * randn(size(img));
blurred_noisy = im2double(blurred) + noise;
% 使用deconvwnr函数进行图像复原
estimated_nsr = noise_var / var(img(:));
wnr_restored = deconvwnr(blurred_noisy, PSF, estimated_nsr);
% 显示图像
subplot(1, 2, 1);
imshow(blurred_noisy);
title('Blurred and Noisy Image');
subplot(1, 2, 2);
imshow(wnr_restored);
title('Restored Image');
```
3. deconvblind函数示例代码:
```matlab
% 读取原始图像
img = imread('lena.png');
% 生成模糊核
PSF = fspecial('motion', 21, 11);
% 生成模糊图像
blurred = imfilter(img, PSF, 'conv', 'circular');
% 使用deconvblind函数进行图像复原
restored = deconvblind(blurred, PSF);
% 显示图像
subplot(1, 2, 1);
imshow(blurred);
title('Blurry Image');
subplot(1, 2, 2);
imshow(restored);
title('Restored Image');
```
以上三个示例代码分别对应使用deconvreg、deconvwnr和deconvblind函数进行图像去卷积处理的示例。您可以根据需要进行修改和调整。
阅读全文
相关推荐















