Computer Vision Applications using
Fourier Transform
Abstract
Fourier Transform is a powerful tool in image processing, providing frequency domain
analysis and manipulation capabilities. This report explores two significant applications:
Frequency Domain Filtering and Image Compression using truncated FFT. The first
application demonstrates low-pass and high-pass filtering using circular masks, while the
second showcases image compression by retaining only a subset of significant frequency
components. These applications validate the practical utility of the Fourier Transform in
improving image quality and reducing storage requirements, highlighting its role in modern
computer vision systems.
1. Introduction
Fourier Transform is a cornerstone in signal and image processing, offering a way to
analyze the frequency content of signals. In image processing, it enables us to move from
the spatial domain to the frequency domain, where filtering and compression techniques
become more efficient and insightful. This report presents two real-world computer vision
applications using the Fast Fourier Transform (FFT) algorithm: frequency domain filtering
and image compression.
1.1 Objectives
- To understand the application of FFT in image processing.
- To implement low-pass and high-pass filters using frequency domain techniques.
- To demonstrate image compression using truncated FFT.
- To analyze and interpret the visual results of frequency domain operations.
2. Design and Implementation
2.1 Design
The applications are designed with the following components:
- Input: Grayscale image (e.g., lena.png)
- Processing: Applying FFT to transform the image to the frequency domain
- Filtering: Using a circular mask for low-pass and high-pass filtering
- Compression: Retaining a central square region of the FFT spectrum
- Output: Visual comparisons between original, filtered, and compressed images
Application 1: Frequency Domain Filtering
- Use FFT to transform the image to frequency domain
- Use a circular low-pass filter mask to suppress high frequencies
- Subtract the low-pass result from the original spectrum for high-pass filtering
Application 2: Image Compression using Truncated FFT
- Use FFT and retain only a central fraction of the frequency spectrum
- Discard other frequency components to simulate compression
- Inverse transform to reconstruct the image
2.2 Implementation
Both applications were implemented using Python with OpenCV and NumPy libraries.
Matplotlib was used for visualization. The steps include image loading, transformation,
mask creation, inverse transformation, and display of results.
3. Project Code
Application 1: Frequency Domain Filtering
import cv2
import numpy as np
import matplotlib.pyplot as plt
image = cv2.imread('lena.png', 0)
f = np.fft.fft2(image)
fshift = np.fft.fftshift(f)
magnitude_spectrum = 20 * np.log(np.abs(fshift) + 1)
rows, cols = image.shape
crow, ccol = rows // 2 , cols // 2
mask = np.zeros((rows, cols), np.uint8)
cv2.circle(mask, (ccol, crow), 30, 1, thickness=-1)
fshift_low = fshift * mask
img_low = np.fft.ifft2(np.fft.ifftshift(fshift_low))
img_low = np.abs(img_low)
fshift_high = fshift * (1 - mask)
img_high = np.fft.ifft2(np.fft.ifftshift(fshift_high))
img_high = np.abs(img_high)
plt.subplot(221), plt.imshow(image, cmap='gray'), plt.title('Original')
plt.subplot(222), plt.imshow(magnitude_spectrum, cmap='gray'), plt.title('FFT Magnitude')
plt.subplot(223), plt.imshow(img_low, cmap='gray'), plt.title('Low-pass Filtered')
plt.subplot(224), plt.imshow(img_high, cmap='gray'), plt.title('High-pass Filtered')
plt.tight_layout()
plt.show()
Application 2: Image Compression with Truncated FFT
import cv2
import numpy as np
import matplotlib.pyplot as plt
image = cv2.imread('lena.png', 0)
f = np.fft.fft2(image)
fshift = np.fft.fftshift(f)
rows, cols = image.shape
keep_fraction = 0.1
mask = np.zeros_like(fshift)
rstart = int(rows*(0.5 - keep_fraction/2))
rend = int(rows*(0.5 + keep_fraction/2))
cstart = int(cols*(0.5 - keep_fraction/2))
cend = int(cols*(0.5 + keep_fraction/2))
mask[rstart:rend, cstart:cend] = 1
f_compressed = fshift * mask
image_compressed = np.fft.ifft2(np.fft.ifftshift(f_compressed))
image_compressed = np.abs(image_compressed)
plt.subplot(131), plt.imshow(image, cmap='gray'), plt.title('Original')
plt.subplot(132), plt.imshow(np.log(np.abs(fshift)+1), cmap='gray'), plt.title('FFT
Spectrum')
plt.subplot(133), plt.imshow(image_compressed, cmap='gray'), plt.title('Compressed
Image')
plt.tight_layout()
plt.show()
4. Result and Discussion
Application 1 Results:
The low-pass filtered image appears smoother with reduced high-frequency noise,
demonstrating effective suppression of fine details. The high-pass filtered image highlights
edges and fine structures, useful in edge detection tasks.
Application 2 Results:
The compressed image retains the general structure of the original with reduced detail,
showing the impact of frequency truncation. Even with 10% of the frequency components,
visual integrity is maintained to a significant extent.
Discussion:
The experiments confirm that frequency-based operations offer control over image
properties such as smoothness and sharpness. FFT filtering is well-suited for applications
such as noise reduction and feature extraction. Image compression via FFT, although lossy,
preserves perceptual quality, making it practical for storage-constrained environments.
5. Conclusion
The report demonstrates the utility of FFT in two distinct but related image processing
tasks—filtering and compression. Frequency domain filtering enables targeted
manipulation of image details, while truncated FFT shows promise for lossy compression
with significant visual retention. These foundational techniques illustrate how
mathematical tools like the Fourier Transform enhance practical capabilities in computer
vision.