FFTShift swaps data in a matrix or a vector into a different position. For a matrix swapped about both dimensions, the quadrants are moved like so.
The Fourier transform of an image places lower frequency data near all four corners, with higher frequency data near the center. In this instance, FFTShift is typically applied to move the lowest frequencies to the center and the highest frequencies to the corners.
This results in a more meaningful visualization of the power spectrum where the lowest frequency data is contiguous, and simplifies the manipulation of frequency data
First, we import an image.
>
|
|
Now, we convert from the image domain to the spatial frequency domain, move the zero-frequency data to the center, and visualize the power spectrum (the square-root scaling simply rescales the frequencies for a more meaningful visualization).
>
|
|
Multiply the spatial frequencies by a Gaussian mask (this is similar to a low pass filter that attenuates higher frequency data).
>
|
|
Move the zero frequency data back to their original positions, and then invert the spatial frequency data back to the image domain.
>
|
|