逆滤波容易受到噪声的影响。最小均方差滤波,该方法建立在图像和噪声都是随机变量的基础上,找出未污染图像 f 的一个估计 f^ ,使他们之间的均方误差最小。
%Read image
I = imread('1.jpg');
[d1,d2,d3] = size(I);
if(d3 > 1)
I = rgb2gray(I);
end
I = im2double(I);
%I = im2double(imread('cameraman.tif'));
figure,subplot(2,3,1),imshow(I);
title('Original Image ');
%Simulate a motion blur
LEN = 100;
THETA = 11;
PSF = fspecial('motion', LEN, THETA);
blurred = imfilter(I, PSF, 'conv', 'circular');
subplot(2,3,2),imshow(blurred);
PSNRblurr=psnr(I,blurred);
title('blurred');
%Restore the blurred image
wnr1 = deconvwnr(blurred, PSF, 0);
subplot(2,3,3),imshow(wnr1);
PSNR1=psnr(I,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')
PSNRnoise=psnr(I,blurred_noisy);
%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')
PSNR2=psnr(I,wnr2);
%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)
PSNR3=psnr(I,wnr3);
title('Restoration of Blurred, Noisy Image Using Estimated NSR');
J = deconvwnr(I,PSF,NSR)
NSR噪声和信号比,显著影响计算结果,计算结果可以用PSNR来度量。
http://blog.csdn.net/zjyruobing/article/details/49908979
http://blog.csdn.net/bluecol/article/details/46242355