2. FFT and Its Applications
FFTSHIFT Shift zero-frequency component
to the center of spectrum. For vectors,
FFTSHIFT(X) swaps the left and right
halves of X. For matrices, FFTSHIFT(X)
swaps the first and third quadrants and the
second and fourth quadrants. For N-D
arrays, FFTSHIFT(X) swaps "half-spaces"
of X along each dimension.
4. Example of 2-D FFT Matlab Code
clear all; close all; clc
%read the original image
i=imread('H:htc mobile photos 3-6-17100MEDIAIMAG0070_1.jpg');
figure (1);imshow(i);title('original image');
%convert to gray image for to process easy
i1=rgb2gray(i);figure (2); imshow(i1); title('grayscale image');
%convert the gray image in to fourier transform image
F=fft2(i1);S=abs(F);figure (3); imshow(S,[]);
title('FT image');
%get the centered spectrum image
Fsh=fftshift(F);SS=abs(Fsh);figure (4); imshow(SS,[]); title('centered spectrum');
%apply log transform of the image
S2=log(1+abs(SS));figure (5); imshow(S2,[]); title('log transfrmed image');
%finally recontruct the image
F=ifftshift(Fsh);f=ifft2(F);figure (6); imshow(f,[]);title('reconstructed image');