1.维纳滤波复原
I=checkerboard(8);
noise=0.1*randn(size(I));
PSF=fspecial('motion',21,11);
Blurred=imfilter(I,PSF,'circular');
BlurredNoisy=im2uint8(Blurred+noise);
NP=abs(fftn(noise)).^2;
NPOW=sum(NP(:)/prod(size(noise));
NCORR=fftshift(real(ifftn(NP)));
IP=abs(fftn(I)).^2;
IPOW=sum(IP(:)/prod(size(noise));
ICORR=fftshift(real(ifftn(IP)));
ICORR1=ICORR(:,ceil(size(I,1)/2));
NSR=NPOW/IPOW;
subplot(221);imshow(BlurredNoisy,[]);
title('模糊和噪声图像');
subplot(222);imshow(deconvwnr(BlurredNoisy,PSF,NSR),[]);
title('deconbwnr(A,PSF,NSR)');
subplot(223);imshow(deconvwnr(BlurredNoisy,PSF,NCORR,ICORR),[]);
title('deconbwnr(A,PSF,NCORR,ICORR)');
subplot(224);imshow(deconvwnr(BlurredNoisy,PSF,NPOW,ICORR1),[]);
title('deconbwnr(A,PSF,NPOW,ICORR_1_D)');
2.规则化滤波复原程序
I=checkerboard(8);
PSF=fspecial('gaussian',7,10);
V=.01;
BlurredNoisy=imnoise(imfilter(I,PSF),'gaussian',0,V);
NOISEPOWER=V*prod(size(I));
[J LAGRA]=deconvreg(BlurredNoisy,PSF,NOISEPOWER);
subplot(221);imshow(BlurredNoisy);
title('A=Blurred and Noisy');
subplot(222);imshow(J);
title('[J LAGRA]=deconvreg(A,PSF,NP)');
subplot(223);imshow(deconvreg(BlurredNoisy,PSF,[],LAGRA/10));
title('deconvreg(A,PSF,[],0.1*LAGRA)');
subplot(225);imshow(deconvreg(BlurredNoisy,PSF,[],LAGRA/10))
subplot(224);imshow(deconvreg(BlurredNoisy,PSF,[],LAGRA*10));
title('deconvreg(A,PSF,[],10*LAGRA');