๐ผ️ Frequency Domain in Computer Vision – A Simple Guide
Images are not just pictures—they are mathematical signals. In computer vision, we can analyze them in two ways:
- Spatial Domain (pixel-based view)
- Frequency Domain (pattern-based view)
This guide explains everything in simple language with math, intuition, and real-world examples.
๐ Table of Contents
- What is an Image?
- Spatial vs Frequency Domain
- Fourier Transform
- Math Explained Simply
- Frequency Spectrum
- Filtering (Low & High Pass)
- Code Example
- CLI Output
- Applications
- Key Takeaways
- Related Articles
๐งฉ What is an Image?
An image is made of pixels.
When combined, these pixels form an image.
But computers can also analyze images differently—not just as pixels, but as patterns.
๐ Spatial vs Frequency Domain
Spatial Domain
You look at pixels directly.
Frequency Domain
You look at how fast pixel values change.
- Slow changes → Low frequency (sky, smooth areas)
- Fast changes → High frequency (edges, textures)
⚙️ Fourier Transform – The Magic Tool
The Fourier Transform converts an image from spatial to frequency domain.
Formula:
\[ F(u,v) = \sum_{x=0}^{M-1} \sum_{y=0}^{N-1} f(x,y)\, e^{-j2\pi\left(\frac{ux}{M}+\frac{vy}{N}\right)} \]
Simple Meaning:
- \(f(x,y)\): original image
- \(F(u,v)\): frequency representation
- It breaks image into waves
๐ Math Explained in Easy Language
Let’s simplify the formula idea:
1. Image as Waves
An image is treated like many overlapping waves.
2. Each Wave = Pattern
- Big smooth waves → low frequency
- Tiny fast waves → high frequency
3. Why exponent?
\[ e^{j\theta} \]
This represents rotation (circular movement) in math, helping capture patterns in different directions.
๐ Frequency Spectrum
After applying Fourier Transform, we get a frequency map.
- Center → Low frequency (smooth areas)
- Edges → High frequency (details, edges)
๐ง Filtering in Frequency Domain
1. Low-Pass Filter
Keeps smooth parts, removes details.
2. High-Pass Filter
Keeps edges and sharp details.
๐ป Code Example (Python OpenCV)
import cv2
import numpy as np
import matplotlib.pyplot as plt
img = cv2.imread('image.jpg', 0)
f = np.fft.fft2(img)
fshift = np.fft.fftshift(f)
magnitude = 20 * np.log(np.abs(fshift))
plt.imshow(magnitude, cmap='gray')
plt.show()
๐ฅ️ CLI Output Example
Click to view output
Input Image Loaded Applying Fourier Transform... Transform Complete Displaying Frequency Spectrum
๐ Real-World Applications
- Noise Reduction in photos
- Edge Detection in object recognition
- Image Compression (JPEG)
- Medical imaging (MRI, CT scans)
๐ก Key Takeaways
- Images can be analyzed as frequencies
- Fourier Transform converts spatial → frequency domain
- Low frequency = smooth areas
- High frequency = details and edges
- Filtering helps enhance or clean images
๐ฏ Final Thoughts
The frequency domain gives us a hidden view of images. Instead of seeing pixels, we see patterns, waves, and structures.
This perspective is essential in modern computer vision, from medical imaging to AI vision systems.
No comments:
Post a Comment