%Display the Fourier Spectrum using MATLAB? 

%Create an image with a white rectangle and 
%black background.
f=zeros(30,30);
f(5:24,13:17)=1;
imshow(f,[])
%Calculate the DFT. Notice how there 
%are real and imaginary parts to F. 
%You must use abs to compute the magnitude 
%(square root of the sum of the squares of the real 
%and imaginary parts). 
F=fft2(f);
F2=abs(F);
figure, imshow(F2,[])
%To create a finer sampling of the Fourier transform, 
%you can add zero
%padding to f when computing its DFT 
F=fft2(f, 256,256);
F2=abs(F);
figure, imshow(F2, [])
%The zero-frequency coefficient is displayed in the upper left hand corner.
%To display it in the center, you can use the function fftshift. 
F2=fftshift(F);
F2=abs(F2);       
figure,imshow(F2,[])
%To brighten the display, you can use a log function 
F2=log(1+F2);
figure,imshow(F2,[])     







