%This illustrates forming a thumnail image by decimating,
%and why antialias (lowpass) filtering is necessary.
clear;load clown.mat;Y1=X(1:8:200,1:8:200);%Decimated original image.
figure,imagesc(X),colormap(gray),axis off,title('Original clown image')
figure,subplot(4,4,1),imagesc(Y1),colormap(gray),axis off,title('Decimated and aliased 25X25 version')
%Antialias lowpass filter original image before decimating:
FX=fft2(X);FY=FX;FY(14:188,:)=0;FY(:,14:188)=0;Y=real(ifft2(FY));Y2=Y(1:8:200,1:8:200);
figure,imagesc(Y),colormap(gray),axis off,title('Lowpass-filtered 200X200 image')
figure,imagesc(fftshift(log10(abs(FY)))),colormap(gray),axis off,...
title('Spectrum of lowpass-filtered image')
figure,subplot(4,4,1),imagesc(Y),colormap(gray),axis off,...
title('Decimated unaliased 25X25 image')