110 likes | 232 Views
Frequancy Domain Filtering (FDF). Lab 5. U sing FFT (Fast Fourier Transform ) algorithm DFT (Discrete Fourier Transform) & inverse DFT. Image Operation in Frequency D omain. Fourier Transform. MATLAB provides a collection of functions for computing and working with Fourier transforms .
E N D
Using FFT (Fast Fourier Transform ) algorithm • DFT (Discrete Fourier Transform) & inverse DFT
Fourier Transform • MATLAB provides a collection of functions for computing and working with Fourier transforms.
fft2 • Y=fft2(X); % X is the spatial image • It Computes and returns a Discrete Fourier transform(DFT) of an image X, computed with Fast Fourier Transform (FFT) algorithm. • Y is the same size of X • The origin of Y(DFT) is at top left, with four quarter meeting at the center of the frequency.
abs • S = abs(Y); • Used to obtain the Fourier spectrum. • It computes the magnitude of each element in the DFT.
fftshift • Yc = fftshift(Y); • Used to move the origin of the DFT to the center(used to compute the centered DFT).
Computing and visualizing the 2D DFT in MATLAB >> X = imread(‘………’); % load in spatial image >> Y = fft2(X); % compute DFT >> S = abs(Y); % compute magnitude for display >> imshow(S,[]); % shows in four corners of display, you can write it as imshow( abs(Y), [] ); >> Yc = fftshift(Y); % shift DFT to center >> imshow(abs(Yc) , [] ); % show magnitude of DFT in center
NOTE • imshow(I,[low high]) displays the grayscale image I • The value low (and any value less than low) displays as black. • the value high (and any value greater than high) displays as white. • Values in between are displayed as intermediate shades of gray. • If you use an empty matrix [] for [low high], imshow uses [min(I(:)) max(I(:))]; that is: • the minimum value in I is displayed as black. • the maximum value in I is displayed as white.
DFT in center can be visually enhanced(increase visual details) by log transformationc*log(1+double(f)) >> Yc2 = log(1 + abs(Yc) ); >> imshow(Yc2, [] ); % or imshow(abs(Yc2), [] );
ifftshift • Y=ifftshift(Yc) • It reverses the centering. • Used to move the origin of the DFT from the center to the top left.