%How motion-blurred images were created:
%load filename.mat;H=ones(1,16)/15;
%Y1=conv2(X(:,:,1),H);Y2=conv2(X(:,:,2),H);Y3=conv2(X(:,:,3),H);
%Y(:,:,1)=Y1;Y(:,:,2)=Y2;Y(:,:,3)=Y3;
clear;load xmasmotion.mat;lamb=.01;N=15;%(from problem)
%Y(:,400,:)=0;%For 10.7 only (zero-pad 399 to 400)
[M1,M2,D]=size(Y);%know D=3.
H=[ones(1,N+1)/N 0];%For 10.7 only (zero-pad 399 to 400) else omit 0.
FH=fft2(H,M1,M2);
Y1=Y(:,:,1);FY1=fft2(Y1,M1,M2);
Y2=Y(:,:,2);FY2=fft2(Y2,M1,M2);
Y3=Y(:,:,3);FY3=fft2(Y3,M1,M2);
figure,imagesc(Y),axis off
figure,imagesc(fftshift(log10(abs(FY1)))),colormap(gray)
FZ1=FY1.*conj(FH)./(abs(FH).*abs(FH)+lamb*lamb);Z1=real(ifft2(FZ1));Z(:,:,1)=Z1;
FZ2=FY2.*conj(FH)./(abs(FH).*abs(FH)+lamb*lamb);Z2=real(ifft2(FZ2));Z(:,:,2)=Z2;
FZ3=FY3.*conj(FH)./(abs(FH).*abs(FH)+lamb*lamb);Z3=real(ifft2(FZ3));Z(:,:,3)=Z3;
Z=(Z-min(min(min(Z))))/(max(max(max(Z)))-min(min(min(Z))));figure,imagesc(Z),axis off


