原
圖像恢復
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