%This illustrates motion blur deconvolution using a Wiener filter.
%A 225X225 image of a sign is motion blurred into a 225X275 motion blurred image.
%The blur has horizontal length 51, and 225+51-1=175. 
%Noisy blurred image looks like noiseless blurred image, so don't bother with latter.
clear;load dui.mat;lambda=1;sigma=10;%Noise strength.
FX=fft2(X,225,275);H(1,1:50)=ones(1,50);FH=fft2(H,225,275);%PSF of motion blur.
Y=real(ifft2(FX.*FH));Y=Y+sigma*randn(225,275);%Noisy motion blurred image.
figure,imagesc(Y),colormap(gray),axis off,title('Noisy motion blurred image')
FZ=fft2(Y,225,275).*conj(FH)./(abs(FH).^2+lambda^2);Z=real(ifft2(FZ));%Wiener filter.
figure,imagesc(Z),colormap(gray),axis off,title('Deblurred image')

