3.7 Linearity, Fourier, Aliasing and deblurring⧉
The previous chapter left us with a debt. We built blur out of convolution, and we noted that blur is not only something we do to an image but something the world does to us: diffraction, a soft lens, a shaky hand, a missed focus. The natural wish is to run that blur backward — to deblur. That wish organizes this entire chapter. Deblurring is an inverse problem: we are handed the blurred image and asked for the sharp one, which means undoing a convolution. Whether that is even possible, and what it costs, turns out to hinge on a single change of viewpoint — seeing the image not as a grid of pixels but as a sum of waves. That viewpoint is the Fourier transform, and reaching it honestly is most of the work here. On the way it hands us, almost as a free gift, the right way to think about sampling and aliasing: the jaggies, the moiré on a striped shirt, the wagon wheel that spins backward in an old film. We cash in the deblurring promise at the very end.
To see why we need new machinery at all, start with two perfectly ordinary operations and the baffling results they can produce (Figure 3.7.1). First, deblurring: take a sharp photo, blur it and add a whisper of noise, then try to undo the blur the obvious way — invert the operation directly. Instead of the sharp original, the result explodes into noise. Second, downsampling: shrink a photo of a building facade by simply keeping every seventh pixel, and bold curved bands appear that are nowhere in the building — phantom moiré. Neither result is a bug; both are doing exactly what we asked. What makes them so hard to reason about is that each operation couples a great many pixels at once — a blur mixes every neighbour into every output, and decimation's fate depends on how the discarded pixels related to the kept ones across the whole image. Staring at the pixels tells us nothing. To understand how these artifacts and patterns emerge — and how to predict, invert, and tame them — we need a different mathematical tool, one in which these many-pixel operations become simple enough to analyze at a glance. That tool is the Fourier transform, and building it is the work of this chapter.
Joseph Fourier (1768–1830) reached his transform not through pure mathematics but through physics — the conduction of heat. In the 1822 Théorie analytique de la chaleur he made the then-scandalous claim that any function, however jagged, can be written as a sum of sines and cosines; contemporaries including Lagrange doubted it, and pinning down exactly when it holds occupied analysts for a century after. The decomposition into frequencies that diagonalizes convolution — the engine of this whole chapter — is his. (Fourier also argued that the atmosphere keeps the Earth warmer than incoming sunlight alone would: the first description of what we now call the greenhouse effect. He was, briefly, Napoleon's governor of Lower Egypt, too.) Portrait: engraving after Julien-Léopold Boilly, early 19th c., public domain (via Wikimedia Commons).
3.7.1 Images as vectors in a high-dimensional space⧉
Begin with a reframing that costs nothing and pays for the whole chapter. A grayscale image with $W \times H$ pixels is simply $W\!\cdot\!H$ numbers. Line them up in a fixed order — unroll the grid row by row into one tall column — and the image becomes a single vector, one point in a space with that many dimensions (Figure 1). A one-megapixel image is a single point in a million-dimensional space. The move feels abstract, but it is exactly what lets us bring linear algebra to bear on images, and linear algebra is the sharpest tool we have for the kind of problem we care about. The flattening is sometimes literal — it is, after all, already how the pixels sit in memory and in a machine-learning tensor — and sometimes only conceptual; the image remains, just as validly, a function over pixel coordinates. (For the linear-algebra vocabulary itself — basis, dot product, orthonormality — see the Refreshers appendix; we lean on Strang's Introduction to Linear Algebra as the standard reference.)
Why does the vector view help? Because a great many image operations are linear: brightening scales the vector, adding two exposures adds the vectors, and — the one that matters here — blur is linear too. Any linear operation on a vector is a matrix. So an optical blur, a motion blur, a Gaussian filter: each is some large matrix $M$ that carries the sharp image $\mathbf{x}$ to the blurred image $\mathbf{y} = M\mathbf{x}$. Deblurring is then, in principle, nothing more dramatic than solving a linear system: invert the matrix, recover $\mathbf{x} = M^{-1}\mathbf{y}$. The entire question of whether we can deblur, and how badly noise will hurt when we try, collapses into a question about a single matrix — and that is a question linear algebra knows how to answer. This dual usefulness, conceptual (a clean language for inverse problems) and practical (we get to call well-tested solvers and libraries), is the reason to adopt the view.
There is one practical worry to dispel immediately. The matrix $M$ for a one-megapixel image is a million by a million — far too large to build, store, or invert directly. The trick, which recurs throughout the book, is that we reason about $M$ without ever forming it. We work out what to do in the abstract language of $M$ and $\mathbf{x}$, then implement it with the cheap image operations that $M$ secretly stands for — a convolution by the blur kernel, a scalar multiply, a dot product of two images. The matrix is the thinking tool; the convolution is the running code. Keeping that separation in mind is what makes the linear-algebra view usable rather than merely elegant.
Linearity is a gift, and we grab it whenever we honestly can. Sometimes the world genuinely is linear: light adds up, optical blur is a true linear operator. Sometimes we must reformulate to expose a linearity hiding underneath — a multiplicative effect becomes additive in log, perspective becomes linear in homogeneous coordinates (later). Sometimes we simplify a messy reality to a linear model on purpose, because linear tools are so much cheaper and better understood. The honest caveat for this chapter's physics: images are usually gamma-encoded for storage, while optical and camera-shake blur happen in linear light — so decode to linear before deblurring. The recurring caution of the book holds: idealized linear math rarely fits reality exactly, but its insights almost always survive the mismatch.
3.7.2 why Fourier⧉
Here is the catch with the matrix view. The blur matrix $M$ is enormous, and although each row is actually quite sparse — every output pixel mixes only the handful of inputs under the kernel, so most entries are zero — that local cross-talk is still painful to reason about and, above all, to invert. Undoing the blur means untangling all the overlapping neighborhoods at once, and the inverse $M^{-1}$ is generally not sparse: a clean local operation can have a thoroughly non-local undo. You cannot eyeball a million-by-million matrix and pronounce whether it can be undone.
There is, however, one species of matrix that is trivial to understand and trivial to invert: a diagonal matrix. A diagonal matrix has no cross-talk whatsoever — each input coordinate is multiplied by its own scalar, independently of every other. Inverting it is then embarrassingly easy: divide each coordinate by that scalar. The entire difficulty of inversion shrinks to one question per coordinate — how close is that scalar to zero? — because dividing by a near-zero number is where all the trouble lives.
So the dream is obvious: we would love the blur matrix to be diagonal. In the pixel representation it is nowhere close. But — and this is the pivot of the chapter — we are free to change how we represent the image, to describe it in a different basis, and a linear operator that looks coupled and hard to invert in one basis can look perfectly diagonal in another. The basis that diagonalizes convolution is precisely the Fourier transform. Change to the Fourier representation and blur stops being a million-dimensional tangle and becomes, instead, a separate scalar multiplication on each frequency — exactly the diagonal case we wished for. (One honest caveat, which we keep flagging: this exact diagonalization assumes the image is cyclic — that it wraps around at its edges like a torus. Real images do not, so the borders misbehave; the insight survives anyway, which is why we lean on it as an analysis tool more than a literal implementation.)
Express a linear operator in a basis where it becomes diagonal. A coupled, hard-to-invert operation in one representation can be a list of independent scalar multiplications in another — and scalars are trivial to understand, compose, and invert. Fourier diagonalizes convolution, turning a blur into per-frequency multiplication. This is not a one-off trick: it is the single most reusable move in applied linear algebra, and it returns for differential equations (the heat equation, below), for principal components, and for nearly every inverse problem in this book. The idea is already visible in the smallest possible case — a $2\times2$ matrix (Figure 3.7.3).
And there is a bonus that makes Fourier feel less like a computational convenience and more like the right language for images. We have already met spatial frequency once, back in perception: the contrast sensitivity function (CSF) describes the eye's sensitivity as a function of how fine or coarse a pattern is — its spatial frequency (see Human perception → Spatial vision / CSF). The visual system is, to a first approximation, organized by frequency. So the Fourier view matches both the mathematics of convolution and the structure of human vision, which is why frequency keeps reappearing — in JPEG compression, in image-quality metrics, in tone mapping. When two unrelated considerations point at the same representation, that representation is usually worth learning.
Before it is a piece of mathematics we impose on images, the Fourier transform is something the physical world already does. Look at a distant point of light — a star, a streetlight — through a small aperture or a camera lens, and the little starburst pattern you see is, almost exactly, the Fourier transform of that aperture (its squared magnitude). A round opening makes the bright central disc and faint rings of the Airy pattern; the polygonal opening of a stopped-down iris makes the radiating sunstar spikes around a bright light, one streak perpendicular to each blade-edge. The optics performs the transform for free, in the instant it takes light to cross the lens — no FFT required. The lesson to take into this chapter is that the Fourier transform is not an arbitrary trick: it is a natural, physical way that waves and apertures already organize themselves, and we are simply borrowing it to organize images. (We meet the optics of this in the OPTICS part, where the lens's frequency response — its modulation transfer function, the Fourier transform of its point-spread blur — is this same picture seen in the frequency domain.)
3.7.3 Definition: one coefficient per wave⧉
Here is the transform itself, in words first. Instead of describing an image by one value per pixel, the Fourier transform describes it by one coefficient per sine wave. We fix a family of sinusoidal patterns — waves of every frequency that fit in the image — and ask, for each one, how much of that wave is present? The list of answers is the Fourier transform $\hat I$ of the image, and because the operation is perfectly reversible, that list carries exactly the same information as the original pixels: it is the same image, written in a different alphabet.
For an $N$-sample one-dimensional signal the recipe is a sum — one output coefficient $\hat I(u)$ for each frequency index $u$. This is the discrete Fourier transform (DFT):
Read it back in words: to find how much of frequency $u$ the signal holds, slide a wave of that frequency across the signal, multiply point by point, and add up — a dot product between the signal and that wave. The complex exponential $e^{-2\pi i\,ux/N}$ is just a compact way to carry a cosine and a sine of frequency $u$ together, by Euler's formula
so the real part of $\hat I(u)$ measures the cosine content and the imaginary part the sine content. Why carry both? Because a single frequency can appear at any phase — shifted left or right — and a cosine and a sine of that frequency together can reproduce a wave of that frequency at any phase and amplitude. One pair, one cosine and one sine, per frequency. (The naive sum costs $O(N^2)$, but the fast Fourier transform (FFT) computes the very same coefficients in $O(N\log N)$ — the algorithm that made Fourier methods practical, and the reason spectral tricks are cheap in code.)
Leonhard Euler (1707–1783) was the most prolific mathematician who ever lived — he kept publishing for years after going blind, dictating from memory. The formula just above, $e^{i\theta}=\cos\theta+i\sin\theta$, is his, and it is what lets a single complex exponential carry a cosine and a sine together — the bookkeeping that makes the Fourier transform compact. His reach into this book is wide: the Euler–Lagrange equations we set to zero to minimize an energy (optical flow, Poisson blending), and the Eulerian "watch a fixed location" view of motion that names half of Feature tracking and all of Video magnification. Portrait: by Jakob Emanuel Handmann, 1753, public domain (via Wikimedia Commons).
A warning to carry out of this chapter, because it will bite the first time you compare a formula against code. The transform above is one of many cosmetically different definitions, and they do not agree digit-for-digit. They differ in the form (the compact complex-exponential here versus separate real sine/cosine series); in where the $2\pi$ lives (in the exponent, folded into the frequency variable, or hidden in the normalization); in which transform you mean (the continuous Fourier transform, the Fourier series of a periodic signal, or the discrete DFT used in code); in the normalization (a $1/N$ on the forward transform, a symmetric $1/\sqrt N$ on each side, or none at all); in the sign of the exponent (forward versus backward — who gets the minus); and in angular versus ordinary frequency. Textbooks, signal-processing courses, and NumPy each pick their own combination, so a formula lifted from one source and dropped into another can be off by a factor, a sign, or a $2\pi$ without any error message to warn you. The rule is simple: always check which convention a source uses before you trust its formula. We use the one above throughout, and — reassuringly — the intuition (a dot product against each wave, convolution becoming per-frequency multiplication) survives every convention unchanged (Figure 3.7.4).