%This illustrates 2-D deconvolution using a Wiener filter,
%which uses Tikhonov regularization to stabilize deconvolution.
clear;load letters.mat;FX=fft2(X,280,280);lambda2=5;sigma2=300;%Noise strength.
figure,imagesc(X),colormap(gray),axis off,title('Letters image f[n,m]')
%0-pad to size of blurred image, which is 276X276. Round 256+21-1=276 to 280.
H=exp(-[-10:10].*[-10:10]/20);FH=fft2(H'*H,280,280);%Gaussian PSF
FY=FH.*FX;Y=real(ifft2(FY));%Blurred image.
Y=Y+sigma2*randn(280,280);%Add noise to blurred image.
figure,imagesc(Y),colormap(gray),axis off,...
title('Noisy blurred image g[n,m]=h[n,m]**f[n,m]+v[n,m]')
FY=fft2(Y);Z=real(ifft2(FY./FH));%Deconvolution without Tikhonov regularization.
figure,imagesc(Z),colormap(gray),axis off,title('f[n,m] without regularization')
FW=conj(FH)./(abs(FH).*abs(FH)+lambda2);W=real(ifft2(FY.*FW));%Wiener filter.
figure,imagesc(W),colormap(gray),axis off,title('f[n,m] with Wiener filter')