原
图像恢复
function image_restoration_deconvwnr()
%Read image
I = im2double(imread('lena.tif'));
I=rgb2gray(I);
figure,subplot(2,3,1),imshow(I);
title('Original Image');
%Simulate a motion blur
LEN = 21;
THETA = 11;
PSF = fspecial('motion', LEN, THETA);
blurred = imfilter(I, PSF, 'conv', 'circular');
subplot(2,3,2),imshow(blurred);
title('Blurred Image');
%Restore the blurred image
wnr1 = deconvwnr(blurred, PSF, 0);
subplot(2,3,3),imshow(wnr1);
title('Restored Image');
%Simulate blur and noise
noise_mean = 0;
noise_var = 0.0001;
blurred_noisy = imnoise(blurred, 'gaussian', ...
noise_mean, noise_var);
subplot(2,3,4),imshow(blurred_noisy)
title('Simulate Blur and Noise')
%Restore the blurred and noisy image:First attempt
wnr2 = deconvwnr(blurred_noisy, PSF, 0);
subplot(2,3,5);imshow(wnr2);title('Restoration of Blurred, Noisy Image Using NSR = 0')
%Restore the Blurred and Noisy Image: Second Attempt
signal_var = var(I(:));
wnr3 = deconvwnr(blurred_noisy, PSF, noise_var / signal_var);
subplot(2,3,6),imshow(wnr3)
title('Restoration of Blurred, Noisy Image Using Estimated NSR');
end
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
维纳滤波需要估计图像的信噪比(SNR)或者噪信比(NSR),信号的功率谱使用图像的方差近似估计,噪声分布是已知的。从第一排中可以看出,若无噪声,此时维纳滤波相当于逆滤波,恢复运动模糊效果是极好的。从第二排可以看出噪信比估计的准确性对图像影响比较大的,二排中间效果几乎不可用。
逆滤波
function image_restoration_matlab()
% Display the original image.
I = im2double(imread('lena.tif'));
I=rgb2gray(I);
[hei,wid,~] = size(I);
subplot(2,3,1),imshow(I);
title('Original Image (courtesy of MIT)');
% Simulate a motion blur.
LEN = 21;
THETA = 11;
PSF = fspecial('motion', LEN, THETA);
blurred = imfilter(I, PSF, 'conv', 'circular');
subplot(2,3,2), imshow(blurred); title('Blurred Image');
% Inverse filter
If = fft2(blurred);
Pf = fft2(PSF,hei,wid);
deblurred = ifft2(If./Pf);
subplot(2,3,3), imshow(deblurred); title('Restore Image')
% Simulate additive noise.
noise_mean = 0;
noise_var = 0.0001;
blurred_noisy = imnoise(blurred, 'gaussian', ...
noise_mean, noise_var);
subplot(2,3,4), imshow(blurred_noisy)
title('Simulate Blur and Noise')
% Try restoration assuming no noise.
If = fft2(blurred_noisy);
deblurred2 = ifft2(If./Pf);
subplot(2,3,5), imshow(deblurred2)
title('Restoration of Blurred Assuming No Noise');
% Try restoration with noise is known.
noisy = blurred_noisy - blurred;
Nf = fft2(noisy);
deblurred2 = ifft2(If./Pf - Nf./Pf);
subplot(2,3,6), imshow(deblurred2)
title('Restoration of Blurred with Noise Is Known')
end
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
逆滤波对噪声非常敏感,除非我们知道噪声的分布情况(事实上,这也很难知道),逆滤波几乎不可用,可以从二排中间看出,恢复图像效果极差。但若知道噪声分布,也是可以完全复原信息的。可以从二排最后一张图可以看出。
参考文献:
数字图像处理matlab版(左飞)
数字图像处理第三版(Gonzalez)
http://blog.csdn.net/zhoufan900428/article/details/38064125
http://blog.csdn.net/bluecol/article/details/47357717
http://blog.csdn.net/bluecol/article/details/46242355