clear;lambda=0.01;
load xmastree.mat;R=20;
%load toucan.mat;R=11;
%load flag.mat;R=29;
%load plumage.mat;R=18;
M1=size(X,1);M2=size(X,2);R2=2*R-1;N1=M1+R2-1;N2=M2+R2-1;H(R2,R2)=0;
for I=1:R2;for J=1:R2;if((I-R)*(I-R)+(J-R)*(J-R)<=R*R);H(I,J)=1;
end;end;end;FH=fft2(H,N1,N2);AFH=abs(FH).*abs(FH);
FX1=fft2(X(:,:,1),N1,N2);FY1=FX1.*FH;Y(:,:,1)=real(ifft2(FY1));
FX2=fft2(X(:,:,2),N1,N2);FY2=FX2.*FH;Y(:,:,2)=real(ifft2(FY2));
FX3=fft2(X(:,:,3),N1,N2);FY3=FX3.*FH;Y(:,:,3)=real(ifft2(FY3));
FZ1=FY1.*conj(FH)./(AFH+lambda*lambda);Z(:,:,1)=real(ifft2(FZ1));
FZ2=FY2.*conj(FH)./(AFH+lambda*lambda);Z(:,:,2)=real(ifft2(FZ2));
FZ3=FY3.*conj(FH)./(AFH+lambda*lambda);Z(:,:,3)=real(ifft2(FZ3));
Y=(Y-min(min(min(Y))))/(max(max(max(Y)))-min(min(min(Y))));
Z=(Z-min(min(min(Z))))/(max(max(max(Z)))-min(min(min(Z))));
figure,imagesc(Y),axis off,figure,imagesc(Z),axis off


