%Construct a matrix f 
f = zeros(30,30);
f(5:24,13:17) = 1;
imshow(f,'notruesize')
%Compute and visualize the 30-by-30 DFT of f with these commands.
F = fft2(f);
F2 = log(abs(F));
%imshow(F2,[-1 5],'notruesize'); colormap(jet); 
imshow(F2,[-1 5],'notruesize');
colormap(jet);
colorbar
F = fft2(f,256,256);
imshow(log(abs(F)),[-1 5]); colormap(jet); colorbar
%The zero-frequency coefficient, however, is still displayed in 
%the upper left corner rather than the center. 
%You can fix this problem by using the function fftshift, 
%which swaps the quadrants of F so that the zero-frequency coefficient is in the center. F = fft2(f,256,256);
F2 = fftshift(F);
imshow(log(abs(F2)),[-1 5]); colormap(jet); colorbar