![]() |
VOOZH | about |
Fourier Transform is a mathematical technique used to analyze the frequency components of an image. It converts an image from the spatial domain to the frequency domain, making it useful for image filtering, compression, enhancement, and feature extraction.
The continuous Fourier Transform is given by:
In this program, we will find the Discrete Fourier Transform (DFT) of an input image using OpenCV. The frequency components are processed and the resulting magnitude spectrum is displayed to visualize the image in the frequency domain.
Input Image:
Importing NumPy for numerical operations, OpenCV for image processing, and Matplotlib for visualization.
Loading the input image in grayscale mode using the cv2.imread() function, as Fourier Transform is typically applied to grayscale images.
Converting the image from the spatial domain to the frequency domain using the cv2.dft() function.
A square mask is created around the center of the spectrum to preserve low-frequency components while suppressing high-frequency components.
The mask is applied to the shifted spectrum. The modified spectrum is then shifted back before performing the inverse transform.
The inverse DFT reconstructs the image from the filtered frequency spectrum. The magnitude is calculated to visualize the intensity of the reconstructed image.
Finally, displaying the original image and the resulting magnitude spectrum using Matplotlib.