Chapter 8The 2D Fourier Transform: Images

Everything so far has been a signal over time. An image is brightness over an (x, y) grid instead — but the same idea works: any image is a sum of simple wave patterns. The trick that makes it practical is that the 2D transform separates into two passes of the exact 1D DFT from Chapter 7 — once across each row, once down each column.

A 2D sine wave

In one dimension, a sine wave is a height that oscillates over time. In two dimensions, it's a brightness that oscillates over space — stripes. Two numbers set the pattern: how fast it oscillates left-right ($u$) and how fast it oscillates up-down ($v$).

cos(2π(ux + vy))
$u$ alone (with $v = 0$) makes vertical stripes — it's a horizontal frequency. $v$ alone makes horizontal stripes. Turn both on and the stripes tilt: you're looking at one single 2D frequency component, exactly the kind of term the formula below sums up by the thousands to build a real image.

Any image is a sum of these

Pick a test pattern below. Next to it is its magnitude spectrum — brighter means more of that frequency is present, and the very center is "no oscillation at all" (the image's average brightness). Frequencies get faster the further out from the center you go, in every direction.

Original
Magnitude spectrum
Reconstructed

Click and drag on the spectrum to set a cutoff radius — everything outside (or inside) it gets zeroed before the image is rebuilt.

2D Discrete Fourier Transform
$$ F(u,v) = \sum_{x=0}^{N-1}\sum_{y=0}^{N-1} f(x,y)\, e^{-i2\pi\left(\frac{ux}{N} + \frac{vy}{N}\right)} $$

That double sum looks new, but it isn't: because it's separable, a program never actually computes it directly. It runs Chapter 7's exact 1D DFT on every row of the image, then runs it again on every column of the result. Two passes of old math, no new algorithm required.

This is JPEG, basically. Drag the low-pass radius down and watch the image blur toward flat gray — you're throwing away high-frequency detail, which is exactly what JPEG compression does (it keeps the frequencies human eyes are sensitive to and discards the rest). Switch to high-pass and only edges survive — the same idea photo-editing "sharpen" and "edge detect" filters run.