2D FOURIER TRANSFORM

Objectives: 2D FOURIER TRANSFORM

2D FOURIER TRANSFORM - FULL EXPLANATORY NOTES

TOPIC 10: 2D FOURIER TRANSFORM (Applied in Image Processing)

1. Introduction

The 2D Fourier Transform (2D-FT) is an extension of the 1D Fourier Transform to two dimensions. It is widely used in image processing because an image can be treated as a two-dimensional signal. The main goal is to analyze how image features vary across different frequencies, which helps in filtering, compression, and enhancement.

2. Mathematical Formula of 2D Fourier Transform

If f(x, y) is a 2D signal (such as a grayscale image), the 2D Fourier Transform is defined as:

F(u, v) = ∫∫ f(x, y) * e^(-j 2π (u*x + v*y)) dx dy
  

Explanation of Symbols:

  • f(x, y): the original spatial domain image
  • F(u, v): the frequency domain representation
  • x, y: spatial coordinates
  • u, v: frequency coordinates
  • j: imaginary unit (√-1)
  • e^(-j 2π (ux + vy)): the complex exponential kernel

Inverse 2D Fourier Transform:

f(x, y) = ∫∫ F(u, v) * e^(j 2π (u*x + v*y)) du dv
  

3. Discrete 2D Fourier Transform (For Digital Images)

Since digital images are stored in a matrix form, we use the Discrete 2D Fourier Transform (D2FT):

F(u, v) = ΣΣ f(x, y) * e^(-j 2π (ux/M + vy/N))
f(x, y) = (1/MN) * ΣΣ F(u, v) * e^(j 2π (ux/M + vy/N))
  
  • M, N: dimensions of the image
  • f(x, y): pixel value at location (x, y)
  • F(u, v): frequency component at (u, v)

4. Applications in Image Processing

A. Frequency Domain Representation

  • Low frequencies represent smooth regions or background.
  • High frequencies represent edges, textures, or noise.

Example: An image with clear edges and sharp transitions will have significant high-frequency components.

B. Filtering in the Frequency Domain

By transforming an image into the frequency domain, we can apply filters to remove or enhance certain features.

Types of Filters:

  • Low-Pass Filter (LPF): allows low frequencies, removes noise and details.
  • High-Pass Filter (HPF): allows high frequencies, enhances edges.
  • Band-Pass Filter: allows a specific range of frequencies.

Filtering Steps:

  1. Compute 2D-FT of image f(x, y)
  2. Multiply with filter mask H(u, v)
  3. Apply inverse 2D-FT to get the filtered image
G(u, v) = H(u, v) * F(u, v)
g(x, y) = Inverse FT of G(u, v)
  

5. Example Calculation (Small Image)

Assume a 2x2 image matrix:

[ 1  2 ]
[ 3  4 ]
  

We compute 2D DFT using the formula. For simplicity, you can apply the matrix multiplication using DFT matrix or use programming tools like NumPy:


import numpy as np
import matplotlib.pyplot as plt
from scipy.fftpack import fft2, fftshift

img = np.array([[1, 2], [3, 4]])
freq = fftshift(fft2(img))
plt.imshow(np.log(np.abs(freq)+1), cmap='gray')
plt.title('Frequency Spectrum')
plt.show()
  

6. Understanding Spectrum Visualization

  • The magnitude |F(u, v)| shows how much of a particular frequency is present.
  • The phase arg(F(u, v)) gives position information.
  • For better viewing:
    • Apply log transform to compress range
    • Shift zero-frequency to center using Fourier shift

7. Benefits of 2D Fourier Transform in Imaging

  • Efficient image compression
  • Accurate edge detection
  • Smooth image restoration (denoising)
  • Fast image comparison in frequency domain

8. Summary

  • 2D-FT converts spatial domain images into frequency domain.
  • Low frequencies = base image
  • High frequencies = sharp features
  • Filtering becomes multiplication in frequency domain.

✨ Challenge to Discover Better Techniques

Learning 2D-FT deeply helps understand:

  • How images contain hidden frequency info
  • How convolution and multiplication are linked
  • How changing frequency components affects image structure

With deeper understanding, one may even develop new transforms — better localized than Fourier, faster than FFT, or more adaptive — that could eventually outperform Fourier in real-world tasks.

20 Solved Examples on 2D Fourier Transform

This section provides 20 carefully solved examples to help master the concepts of 2D Fourier Transform. Each example progresses from simple to complex and emphasizes deep understanding of the formulas and their meanings.

Symbols Explanation (Used Throughout)

  • f(x, y) - The input spatial image value at position (x, y)
  • F(u, v) - The output frequency domain value at frequency (u, v)
  • M, N - The width and height of the image matrix
  • j - The imaginary unit, square root of -1
  • e - Euler's constant, used in complex exponential functions
  • π - Pi, approximately 3.14159

Example 1: 1x1 Image

Input: f(x, y) = [[5]]

Solution: F(u, v) = 5 (constant signal has only DC component)

Example 2: 2x2 Image with Uniform Values

Input:
[1 1]
[1 1]
  

F(0,0) = 1+1+1+1 = 4
All other frequency components = 0
Because there's no variation (only DC)

Example 3: 2x2 Image with Horizontal Edge

[1 1]
[0 0]
  

Shows high frequency in vertical direction (y), low in horizontal (x)

Example 4: Simple Edge Pattern

[0 1]
[0 1]
  

Shows horizontal frequency variation

Example 5: Alternating Checkerboard 2x2

[1 -1]
[-1 1]
  

F(0,0) = 0
High frequency in both directions

Example 6: Compute DFT for 2x2

[1 2]
[3 4]
  

Apply:
F(0,0) = 1+2+3+4 = 10
F(0,1) = 1 - 2 + 3 - 4 = -2
F(1,0) = 1 + 2 - 3 - 4 = -4
F(1,1) = 1 - 2 - 3 + 4 = 0

Example 7: Impulse in Corner

[1 0]
[0 0]
  

All frequencies present. Acts like white noise.

Example 8: Using DFT Formula on 2x2 Image

Use the DFT formula manually:
F(u,v) = sum of f(x,y) * e^(-j2π(ux/M + vy/N)) for all x,y

Example 9: Image with One Row Active

[0 0 0 0]
[1 1 1 1]
[0 0 0 0]
[0 0 0 0]
  

Strong frequency at vertical axis (because of row variation)

Example 10: Vertical Bar Image

[0 1 0 1]
[0 1 0 1]
[0 1 0 1]
[0 1 0 1]
  

Strong horizontal frequency. Appears as alternating columns.

Example 11: DC Image (Constant)

[4 4 4]
[4 4 4]
[4 4 4]
  

Only F(0,0) = total sum = 36. Rest all zero.

Example 12: Single High Pixel

[0 0 0]
[0 9 0]
[0 0 0]
  

Frequencies distributed evenly. Phase matters now.

Example 13: High Frequencies Block

[1 -1 1 -1]
[-1 1 -1 1]
[1 -1 1 -1]
[-1 1 -1 1]
  

Pattern alternates every pixel → highest frequency present.

Example 14: Low Pass Filtering

Use a circular filter that only passes low frequencies
Result: Blurred image, edges are softened

Example 15: High Pass Filtering

Blocks center and passes outer frequencies
Result: Edges enhanced, background suppressed

Example 16: Add Noise and Remove with DFT

Add white noise → observe in frequency spectrum as wide spread
Apply LPF mask → denoise the image

Example 17: Apply Fourier Shift

Shift zero-frequency to center using fftshift
Helps in better visualization and design of filters

Example 18: Reconstruct Image Using Inverse DFT

Take F(u,v), apply inverse DFT:
f(x,y) = sum of F(u,v) * e^(j2π(ux/M + vy/N))

Example 19: Analyze Edge with Fourier

Use vertical or horizontal edge mask (like Sobel), compare spatial vs frequency detection.

Example 20: Apply on Real Image (Python)


import cv2
import numpy as np
from matplotlib import pyplot as plt

img = cv2.imread('image.png', 0)
f = np.fft.fft2(img)
fshift = np.fft.fftshift(f)
magnitude = 20 * np.log(np.abs(fshift))
plt.imshow(magnitude, cmap='gray')
plt.title('Fourier Transform')
plt.show()
  

This reveals the frequency content of real images — edges, details, and repetitive patterns become visible in frequency space.

Conclusion

These 20 examples build a full understanding from simple DC images to advanced concepts like filtering and reconstruction. Mastering this process enables one to handle complex real-world problems in signal and image processing.

Reference Book: N/A

Author name: SIR H.A.Mwala Work email: biasharaboraofficials@gmail.com
#MWALA_LEARN Powered by MwalaJS #https://mwalajs.biasharabora.com
#https://educenter.biasharabora.com

:: 2.0::