PIXELBANKv8.2.1
Menu

Frequency Domain Filtering

Implement image filtering in the frequency domain using FFT.

Convolution in spatial domain = multiplication in frequency domain: F(fg)=F(f)F(g)\mathcal{F}(f * g) = \mathcal{F}(f) \cdot \mathcal{F}(g)

Algorithm:

  1. Compute FFT of image: F=F(I)F = \mathcal{F}(I)
  2. Create frequency domain filter HH (same size as image)
  3. Multiply: G=FHG = F \cdot H
  4. Inverse FFT: Ifiltered=F1(G)I_{filtered} = \mathcal{F}^{-1}(G)

Common filters:

  • Low-pass: Keep center (low frequencies) → blur
  • High-pass: Keep edges (high frequencies) → sharpen
  • Band-pass: Keep ring of frequencies

Example:

Input:
image = 64×64 image with edges
filter_type = 'lowpass'
cutoff = 0.1
Output:
Blurred image (edges smoothed)
Reasoning:
  1. FFT shifts image to frequency domain
  2. Create circular mask: 1 inside radius cutoff*max_freq, 0 outside
  3. Multiply FFT by mask (kills high frequencies)
  4. Inverse FFT → blurred image

Low cutoff = more blur (fewer frequencies retained)

Constraints:

  • image: 2D grayscale array
  • filter_type: 'lowpass', 'highpass', or 'bandpass'
  • cutoff: Cutoff frequency (0-1, fraction of max frequency)
  • Return: Filtered image (real part)
Editor

Test Results

0/0
Run code to see test results.