Applications Gallery

A working JPEG compressor, MRI scanner and Wi-Fi link

Fourier is Everywhere

Every time you play a song, snap a photo, or join Wi-Fi, a Fourier transform is running somewhere. Below are three working machines built on one: an image compressor, an MRI scanner and a radio link.

They are a small sample. Noise-cancelling headphones analyse incoming sound by frequency; seismologists read the Earth's interior from the spectra of earthquake waves; speech recognisers start from spectrograms; X-ray crystallography recovers molecules from diffraction patterns, which are Fourier transforms; radar measures speed from frequency shifts; and Shor's factoring algorithm hinges on a quantum Fourier transform.

A JPEG Compressor

Drag the quality slider down and watch the estimated size fall. Tap the image to move the zoom window and compare the original and compressed pixels up close; the grid of numbers is the green block's quantised coefficients, and most of them are zero. Switch the view to see every block's coefficients, or the error.

Decoded image: tap to move the zoom
Original, ×8
Compressed, ×8
Quantised DCT coefficients of the green block (DC top-left)
-8
8
9
5
3
1
1
0
13
-3
-2
-1
-1
0
0
0
0
0
0
0
0
0
0
0
-10
2
1
1
0
0
0
0
-9
1
1
0
0
0
0
0
-4
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
≈ 3.6 KB
estimated size (raw 64 KB)
17.6 : 1
compression ratio
93.1%
coefficients rounded to zero
31.0 dB
PSNR (higher = closer)

Grayscale baseline JPEG: the standard luminance table, scaled by quality the way libjpeg does it. The size is an estimate of the entropy-coded data, counted the way baseline JPEG spends bits (with typical Huffman code lengths and no headers), so treat it as a guide to how size moves with quality rather than an exact file size.

Go deeper:How JPEG Works

JPEG cuts the image into 8×8 blocks and takes the 2D discrete cosine transform (DCT) of each. The DCT is a Fourier transform that uses only cosines, which avoids a false jump where the block's right edge meets its left. The result is 64 coefficients per block: the average brightness in the top-left corner, then patterns that get finer to the right and downwards.

Each coefficient is divided by a step from the quantisation table and rounded to a whole number. The steps are small for coarse patterns and large for fine ones, because the eye notices fine detail least. Lower quality scales every step up, so more coefficients round to zero.

The coefficients are then read in a zig-zag from coarse to fine, so the zeros bunch up at the end, and run-length and Huffman coding squeeze them out. Only the rounding loses information; every other step is exactly reversible.

Go deeper:Reading the Artifacts

Blocking: each block is compressed on its own. At low quality a block may keep only its average, and you see a mosaic of flat 8×8 tiles with visible seams. Turn on the grid to see that they line up exactly.

Ringing: near a sharp edge, like the checkerboard's corners or the house's windows, the missing fine cosines leave ripples. It is the Gibbs effect again, the same overshoot a square wave shows when its series is cut short.

Smooth areas such as the sky cost almost nothing, while the grass texture and the fence keep many coefficients. That is why photos of foliage make larger JPEGs than photos of clear skies.

Go deeper:The Same Trick for Sound: MP3

MP3 and AAC use a close relative, the Modified Discrete Cosine Transform (MDCT), on short overlapping slices of audio. A psychoacoustic model then decides which frequencies the ear cannot hear, because a louder sound nearby masks them or because they fall below the threshold of hearing, and quantises those coarsely or drops them. The result is around a tenth of the size of CD audio with little audible difference.

MRI: Filling k-Space

An MRI scanner never measures pixels. It measures the image's 2D Fourier transform, called k-space, one line at a time, and the picture on the right is the inverse FFT of the lines measured so far. Try centre-out to see why the middle matters most, then skip lines to halve the scan time and watch the ghosts appear.

k-space measured so far (cyan = latest line)
Image = |inverse FFT| of the measured data
0.0 min
scan time at 0.5 s per line
100%
of a full scan's lines
0.245
RMS error vs the true image
Measuring the centre first gives a recognisable, blurry head almost immediately. The rest of the scan only sharpens it.
Go deeper:Why MRI Measures Frequencies

In a strong magnetic field, hydrogen nuclei precess at a rate proportional to the field. The scanner adds gradient fields that make the field, and so the precession rate, vary with position. The radio signal the body sends back is then a sum of frequencies that encode where the tissue is: exactly one sample of the image's Fourier transform at a time.

Each repetition of the pulse sequence reads one line of k-space, and each takes time, often hundreds of milliseconds. A full 256-line image can take several minutes, which is why scan time is the thing everyone wants to cut.

The centre of k-space holds the low frequencies, the overall shape and contrast. The edges hold the fine detail. A scan with only the centre gives a blurry but correctly shaded image.

Go deeper:Ghosts and Faster Scans

Measuring every other line is the same as sampling k-space at half the rate, and sampling too coarsely in one domain makes copies in the other. The field of view halves, so the parts of the head outside it fold back on top: that is aliasing, the same effect that makes wagon wheels spin backwards on film.

Real scanners use this deliberately. Parallel imaging skips lines and uses several receiver coils, each seeing the body from a different place, to unfold the ghosts. Compressed sensing skips lines at random, so the missing data looks like noise rather than ghosts, and then searches for the simplest image consistent with the data. Both can cut scan times by a factor of two to eight.

A Wi-Fi Link: OFDM

Follow one symbol through panels 1 to 4: bits become points on each subcarrier, an inverse FFT turns them into one time signal, the channel adds noise, and the receiver's FFT recovers the points in panel 5. Lower the signal-to-noise ratio until points land in the wrong square, then turn on the echo and try switching the cyclic prefix and the equaliser off.

1 / 40
OFDM symbols sent
0
bit error rate (0 wrong)
1.60
bits per sample, prefix included

Each symbol: 32 random bits → 16 constellation points → one 16-point inverse FFT → a 4-sample cyclic prefix copied from the end, then the channel → drop the prefix → FFT → divide each subcarrier by the channel’s response → nearest point. Red marks bits that came out wrong. The echo arrives 3 samples late at 55% strength.

Go deeper:How OFDM Works

Orthogonal Frequency Division Multiplexing sends data on many closely spaced frequencies, the subcarriers, at once. Each subcarrier carries one constellation point per symbol: with QPSK that is 2 bits (one of four phases), with 16-QAM 4 bits (one of sixteen amplitude-and-phase combinations). Wi-Fi uses up to 1024-QAM, 10 bits per subcarrier, when the signal is clean.

Building the sum of all those waves is exactly an inverse FFT, and pulling them apart again is an FFT. The subcarriers are orthogonal: over one symbol each completes a whole number of cycles, so the FFT separates them perfectly even though their spectra overlap. Wi-Fi, 4G and 5G, digital TV and DAB radio all work this way.

Noise blurs each received point into a cloud. When the clouds spill over the decision lines, bits flip. 16-QAM packs points closer together, so it carries twice the data of QPSK but needs a cleaner signal: real links switch between them as conditions change.

Go deeper:Echoes and the Cyclic Prefix

Indoors, the signal reaches you directly and again a moment later off the walls. On a single fast carrier, those echoes smear each bit into the next. OFDM's answer is the cyclic prefix: copy the last few samples of each symbol and send them first. As long as the echo is shorter than the prefix, the echo of one symbol never reaches the next, and within a symbol the echo acts like a circular convolution.

By the convolution theorem, circular convolution becomes multiplication after the FFT. Each subcarrier is simply scaled and rotated by one complex number, the channel's response at that frequency, which you can see by turning the echo on with the equaliser off: the constellation scatters into rotated, resized copies, one per subcarrier. The equaliser divides each subcarrier by its number and the points snap back. Remove the prefix and the echo leaks between symbols, and no division can undo it.

Go deeper:Why Is Fourier So Universal?

All three machines rely on the same fact: sines and cosines pass through linear, time-invariant systems (an echoing room, a blurring lens, a precessing nucleus) unchanged in shape, only scaled and shifted. Describe a signal by its frequencies and those systems become simple multiplication.

The FFT, published by Cooley and Tukey in 1965 (and anticipated by Gauss around 1805), made the transform cheap enough to run everywhere. It now sits inside nearly every phone, camera, scanner and radio.

Spot a mistake or have an idea?

Search