Frequency domain filtering
Frequency-domain filtering uses the 2D Fourier transform to design and apply filters (ideal, Butterworth, Gaussian, high/low-pass) by multiplying the image spectrum with a transfer function and then inverse-transforming to get the filtered image.
Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Frequency-domain filtering is used when we want to design filters that act on broad image structures (low frequencies) or fine details/edges (high frequencies), when non-separable or very large-kernel spatial filters are inefficient, and when we must analyze or modify the image spectrum (for denoising, sharpening, periodic noise removal, or optical system compensation).
Key ideas
Fourier transform (continuous 2D): transforms a spatial function to frequency domain. We will work with discrete images and the 2D-DFT.
2D-DFT (definition). For a discrete image f(x,y) of size M × N, the 2D discrete Fourier transform F(u,v) is defined by the exact formula universities expect: Draw diagram to answer: draw a rectangle labeled M (rows) by N (columns); show indices x from 0..M-1 across rows and y from 0..N-1 across columns; show frequency grid u=0..M-1, v=0..N-1. Label F(u,v) at top right of diagram.
Mathematical statement (assumption: indices start at 0): F(u,v) = Σ_{x=0}^{M-1} Σ_{y=0}^{N-1} f(x,y) · e^{-j 2π (u x / M + v y / N)}
and the inverse 2D-DFT is f(x,y) = (1 / (M N)) Σ_{u=0}^{M-1} Σ_{v=0}^{N-1} F(u,v) · e^{+j 2π (u x / M + v y / N)}
State assumptions: f(x,y) is finite and indexed 0..M-1,0..N-1. DFT assumes periodic extension outside the M×N grid (this leads to circular convolution behavior).
Convolution theorem (discrete). If g(x,y) is a filter kernel and * denotes convolution, then (with circular convolution implicit for DFT): DFT{f * g}_circular = F(u,v) · G(u,v)
Exact exam-level statement: The DFT of the circular convolution of two length-M×N signals equals the pointwise product of their DFTs. For linear convolution using DFTs, first zero-pad f and g to size at least (M+P-1)×(N+Q-1) where g has size P×Q; then DFT, multiply, inverse DFT and crop result to the linear convolution size.
Derivation sketch (step-by-step university style):
- Start from definition of DFT of circular convolution: H(u,v)=Σ_x Σ_y [Σ_m Σ_n f(m,n) g((x-m)mod M,(y-n)mod N)] e^{-j2π(ux/M+vy/N)}.
- Exchange summation order (finite sums). 3) Recognise inner sum over x,y becomes product of two exponentials that separate m,n from x,y; performing the sums yields F(u,v)G(u,v). Conclude H(u,v)=F(u,v)G(u,v).
Filtering in frequency domain. To filter an image using frequency methods, multiply the DFT of the image F(u,v) by a filter transfer function H(u,v) (same size). Then apply inverse DFT to get filtered image g(x,y). If H is designed as low-pass, it attenuates high-frequency coefficients; high-pass emphasizes them.
Transfer function H(u,v): the frequency-domain representation of the filter. Common types:
- Ideal low-pass (ILPF): H(u,v)=1 if D(u,v) ≤ D0 else 0. Sharp cutoff — causes ringing (Gibbs) in spatial domain.
- Butterworth low-pass (BLPF) of order n: H(u,v)=1 / (1 + (D(u,v)/D0)^{2n}). Smooth roll-off, less ringing as n is small.
- Gaussian low-pass (GLPF): H(u,v)=exp(-D(u,v)^2/(2 D0^2)). No ringing, smoothest.
- Ideal high-pass (IHPF): H(u,v)=0 if D(u,v) ≤ D0 else 1.
- Butterworth high-pass (BHPF) of order n: H(u,v)=1 / (1 + (D0/D(u,v))^{2n}) = 1 − H_Butterworth_lowpass(u,v); define H(0,0)=0 to avoid division by zero.
- Gaussian high-pass (GHPF): H(u,v) = 1 − exp(-D(u,v)^2/(2 D0^2)). Here D(u,v) is the Euclidean distance from frequency origin.
Centering (shift property): DFT places the zero-frequency at (0,0) corner. For easy design/drawing, shift the origin to center by multiplying the spatial image by (-1)^{x+y} before DFT, and multiply by (-1)^{x+y} again after the inverse DFT to undo the shift. Equivalently, rearrange frequency quadrants by index shift: F_centered(u,v) = F((u+M/2) mod M, (v+N/2) mod N). Statement: multiplying f(x,y) by (-1)^{x+y} shifts the spectrum so low frequency appears at center. Draw: show M×N image with checkerboard (-1)^{x+y} multiplication then arrow to frequency grid with DC centered.
Zero-padding and wrap-around: DFT-based multiplication produces circular convolution. To perform linear filtering (avoid wrap-around), zero-pad image and kernel so padded size P ≥ M + P_k - 1, Q ≥ N + Q_k - 1 (where kernel size is P_k×Q_k). Typical practical rule for image filtering is to pad each dimension to at least the next power-of-two for FFT speed: M' ≥ M + P_k - 1 and N' ≥ N + Q_k - 1.
Magnitude and phase: the DFT coefficients are complex. Magnitude |F(u,v)| and phase ∠F(u,v) together reconstruct the image. Phase carries important structure (edges), magnitude carries energy distribution. For real-valued f(x,y), F(u,v) has conjugate symmetry: F(u,v) = F*((M−u) mod M, (N−v) mod N).
Formulas
F(u,v) = Σ_{x=0}^{M-1} Σ_{y=0}^{N-1} f(x,y) · e^{-j 2π (u x / M + v y / N)} — F(u,v) is complex spectrum. Units: same as intensity with this scaling; frequency axes are in bins (u,v) or normalized cycles/pixel (u/N, v/M); applies to discrete M×N image.
f(x,y) = (1/(M N)) Σ_{u=0}^{M-1} Σ_{v=0}^{N-1} F(u,v) · e^{+j 2π (u x / M + v y / N)} — inverse DFT reconstructs spatial image. Units: intensity.
DFT{f * g}_circular = F(u,v) · G(u,v) — product of spectra equals DFT of circular convolution. Applies to circular convolution of M×N sequences.
D(u,v) = sqrt((u - u0)^2 + (v - v0)^2) — Euclidean distance from frequency origin at (u0,v0) (often center). Units: index distance (frequency bins); to express cycles/pixel use normalized coordinates (u/N, v/M).
H_ILPF(u,v) = 1 if D(u,v) ≤ D0 else 0 — Ideal low-pass.
H_Butterworth(u,v) = 1 / (1 + (D(u,v)/D0)^(2n)) — Butterworth low-pass; n is integer order (dimensionless).
H_Gaussian(u,v) = exp(-(D(u,v)^2)/(2 D0^2)) — Gaussian low-pass; D0 is the scale (standard deviation) in frequency units (note: it is not the −3 dB cutoff).
Centering multiplication: f_c(x,y) = f(x,y) · (-1)^{x+y} — shifts zero-frequency to center of DFT. Apply before the DFT and multiply by (−1)^{x+y} again after the inverse DFT to undo; equivalently, rearrange quadrants in frequency: F_c(u,v) = F((u+M/2) mod M, (v+N/2) mod N).
Zero-padding sizes: P ≥ M + P_k - 1, Q ≥ N + Q_k - 1 — pad image to P×Q before DFT to realize linear convolution of M×N with P_k×Q_k kernel.
Worked examples
Example 1 — small numeric 2×2 DFT filtering (exam-style) Given image f of size 2×2: f(0,0)=1, f(0,1)=2, f(1,0)=3, f(1,1)=4. Use a frequency-domain ideal low-pass filter that keeps only DC (u=0,v=0) and zeros others. Compute filtered image. Steps:
- Compute 2D-DFT F(u,v) for u,v ∈ {0,1}.
Formula: F(u,v)=Σ_x Σ_y f(x,y) e^{-jπ(ux+vy)} because M=N=2 and 2π(u x/2)=π u x.
Compute:
- 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 So F = [[10, -2], [-4, 0]].
- Apply ideal low-pass H that keeps only DC: H = [[1, 0], [0, 0]]. Multiply pointwise: G = F·H = [[10, 0], [0, 0]].
- Inverse DFT to get filtered f'(x,y): f'(x,y) = (1/4) Σ_u Σ_v G(u,v) e^{jπ(ux+vy)}. Only G(0,0)=10 contributes: f'(x,y) = (1/4)·10 = 2.5 for every (x,y). Final answer: filtered image f' = [[2.5, 2.5], [2.5, 2.5]] (all values in intensity units). Bold: 2.5 at every pixel.
Example 2 — compute Butterworth filter value Design a 1st-order Butterworth low-pass (n=1) with cutoff D0 = 2 (index units). For a frequency point whose distance from center is D = 1.5 (index units), compute H. Formula: H = 1 / (1 + (D/D0)^{2n}) Calculation: (D/D0) = 1.5/2 = 0.75 → (0.75)^{2} = 0.5625 → 1 + 0.5625 = 1.5625 → H = 1 / 1.5625 = 0.64 Final: H = 0.64 (dimensionless multiplier on spectrum).
Example 3 — padding rule application (short answer) Filter kernel size 5×5, image size 256×256. To avoid wrap-around use padded size at least (256+5-1)×(256+5-1) = 260×260. For efficient FFT, choose next power-of-two sizes like 256→512; but minimum to avoid circular wrap-around is 260×260.
Common mistakes
- Expecting ideal filters to be artifact-free — ideal (brick-wall) filters cause ringing due to sharp truncation in frequency.
- Confusing spatial filter kernel multiplication (pointwise) with frequency-domain multiplication (pointwise) — spatial filtering convolution corresponds to frequency multiplication, but direct multiplication of spatial image by kernel is different.
- Dropping the 1/(MN) factor in the inverse DFT or misplacing signs in exponents.
- Treating magnitude-only filtering as sufficient — ignoring phase can destroy important structure.
For your exam
Kinds of questions:
- Definitions and short notes: define 2D-DFT, convolution theorem, transfer function, explain centering.
- Derivations: derive convolution theorem for discrete 2D DFT; show why multiplication by (-1)^{x+y} centers the spectrum.
- Numericals: compute small DFTs by hand (2×2 or 3×3), apply simple H(u,v) and inverse DFT, compute Butterworth/Gaussian values.
- Design: compare ideal vs Butterworth vs Gaussian for a given D0 and discuss artifacts.
- Diagrams: draw frequency grid, show origin at corner and centered; mark passband for ideal low-pass and label D0.
What full-marks answers include:
- Clear definitions (bold terms), correct formulas with index ranges, statement of assumptions (periodicity/circular convolution), step-by-step algebra for derivations, correct numeric steps with units, and mention of artifacts (ringing, wrap-around) and padding choices.
Quick check
- What multiplication in spatial domain shifts the DFT origin to the center? 2) State the discrete convolution theorem in one sentence. 3) For a Gaussian low-pass with D0, is there ringing in the spatial domain? Answers: (-1)^{x+y}; DFT of circular convolution equals product of DFTs (DFT{f * g}_circular = F·G); No, Gaussian has no ringing (it is smooth).
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?