%This illustrates lowpass filtering on the clown image.
clear;load clown;figure,imagesc(X),colormap(gray),axis off,title('Clown face image f(x,y)')
FX=fft2(X,1024,1024);FY=FX;FH=ones(1024,1024);
figure,imagesc(log10(fftshift(abs(FX)))),colormap(gray),axis off,title('Magnitude spectrum of clown image F(\mu,\nu)')
FY(129:1026-129,:)=0;FY(:,129:1026-129)=0;%Lowpass filtered spectrum.
FH(129:1026-129,:)=0;FH(:,129:1026-129)=0;%FY=FX.*FH;
Y=real(ifft2(FY));H=real(ifft2(FH));
figure,imagesc(fftshift((abs(H)))),colormap(gray),axis([513-20 513+20 513-20 513+20]),axis off,...
title('Magnified PSF h(x,y) of 2-D LPF')%Actually |h(x,y)| so can take its log.
figure,imagesc(log10(fftshift(abs(FH)))),colormap(gray),axis off,title('Spatial frequency response of 2-D LPF H(\mu,\nu)')
figure,imagesc(Y(1:200,1:200)),colormap(gray),axis off,title('Lowpass filtered clown image g(x,y)')
figure,imagesc(log10(fftshift(abs(FY)))),colormap(gray),axis off,title('Magnitude spectrum of filtered image G(\mu,\nu)')


