BookNotesSlidesP-sets Syllabusdraft · v0.2.64.1
◀▲⌂▶
💬Comments welcome. To leave a note, select any text and click the note / highlight button that pops up — or open the panel with the tab at the top-right (‹). Notes are visible only inside our private review group.
Course notes · 46 sections from the book · 32 optionalPDFessentials+ usefuleverythingthe full book ↗
💡 In a hurry? Jump to this chapter’s 14 big lessons ↓

Lecture Notes 19 — Depth of field⧉

Course notes cut from Computational Photography, an AI-powered Slopendium for this lecture. Each section links back to its home in the book; sections marked optional go beyond what the lecture needs.

Contents · 42 sections on this page, from 16 chapters of the book
2FUNDAMENTALS OF IMAGING
6LINEAR METHODS AND FOURIER ANALYSIS
16DEBLURRING
22COMPOUND LENSES, AND ABERRATION CORRECTION
23DEPTH OF FIELD
31LIGHT FIELDS AND PLENOPTIC CAMERAS
33COMPUTATIONAL OPTICS AND CODED IMAGING
40HUMAN FACTORS

Titles jump to the section below; ↗ opens it in the book.

Light and optics⧉

Wave effects, diffraction, and the diffraction limit⧉

optional

The wave picture imposes a limit on every imaging system ever made. When light passes through a small aperture or skims a sharp edge, it does not continue in perfectly straight rays: it diffracts, bending and spreading out. And, counterintuitively, the smaller the aperture, the more the light spreads (Figure 2.1.45). A wide opening lets the wavefront through almost undisturbed; a narrow one forces it to fan out, through an angle of roughly $\theta \approx \lambda / D$ for an aperture of diameter $D$.

fig-diffraction-aperture-size
Figure 2.1.45 (reproduced). A smaller aperture diffracts more. Light passing a large aperture continues nearly straight; passing a small aperture it fans out far more widely, through an angle of order θ ≈ λ/D. The narrower the opening, the larger the spread, the opposite of the ray-optics intuition, and why shrinking a camera's aperture past a point blurs rather than sharpens. This is a schematic simplification: the diffracted wave has no hard edge or "cone": its intensity simply falls off with angle (shown here by fading the wavefronts), and the true pattern has the side lobes and smooth envelope of the wave-equation solution in the next figure (Figure 2.1.46).

Where does that spreading come from? It is purely a property of waves, and we can watch it happen by solving the wave equation directly. Send a flat wavefront at an opaque barrier with a single slit and let the wave evolve in time: in front of the slit the wavefronts stay flat, but the moment they pass through, they bow into expanding circular arcs and fan outward (Figure 2.1.46). Narrow the slit relative to the wavelength and the fan opens wider: exactly the $\theta \approx \lambda / D$ behavior, now an emergent consequence of the wave dynamics rather than a rule asserted.

fig-diffraction-wave-sim
Figure 2.1.46 (reproduced). Diffraction, simulated. A live 2-D solution of the wave equation: a plane wave arrives from the left and passes through a single slit in an opaque barrier. Before the slit the wavefronts are flat; after it they bend into expanding arcs and spread, and the time-averaged intensity on the far screen forms the single-slit pattern, a broad central lobe flanked by weaker side lobes. Narrowing the slit (or lengthening the wavelength) widens the spread. This is the near-field (Fresnel) pattern at that fixed screen distance, not the textbook far-field sinc²: a narrow slit is already effectively in its far field and shows one broad lobe, while a wide slit still roughly projects its own width, fringed by edge diffraction; the region left of the slit also shows genuine standing-wave interference between the incoming wave and the part reflected off the barrier. Interactive: press play and vary the slit width and wavelength to watch the wave evolve.

The Airy disk. The consequence for imaging is unavoidable: a finite aperture cannot focus light to a perfect point. Even a flawless, aberration-free lens images a single distant point not as a point but as a small bright blur, the Airy disk, surrounded by faint rings, whose angular radius is

$$ \theta \approx 1.22\,\frac{\lambda}{D}, $$

giving a blur-spot diameter on the order of $2.44\,\lambda N$, where $N = f/D$ is the lens's f-number (Figure 2.1.47). The Airy pattern describes an aberration-free, uniformly illuminated circular pupil in the scalar far-field model. Other pupil shapes or weightings change its central lobe and sidelobes; the quoted diameter measures the first dark ring, not the entire extent of the blur.

fig-airy-disk
Figure 2.1.47 (reproduced). The Airy disk: the diffraction-limited blur. A perfect lens images a point source not as a point but as a bright central disk ringed by faint maxima, the Airy pattern. Its angular radius is θ ≈ 1.22 λ/D; the central spot's diameter is ≈ 2.44 λN in f-number terms. This is the smallest spot the lens can make: the floor on resolution set by diffraction, independent of any aberration.

The diffraction limit. Because two nearby point sources blur into two overlapping Airy disks, there is a finest detail a lens can resolve: the diffraction limit. By the Rayleigh criterion, two points are just resolvable when the center of one Airy disk falls on the first dark ring of the other, again at $\theta \approx 1.22\,\lambda/D$. The headline is that a larger aperture diffracts less and resolves finer detail. It is worth putting numbers to that, because the limit is not an abstraction: it decides whether a given lens can read a license plate across a street or separate two stars (Figure 2.1.48).

fig-diffraction-limit-calculator
Figure 2.1.48 (reproduced). What a given aperture can actually resolve. The Rayleigh angle $\theta = 1.22\,\lambda/D$ turns into a finest resolvable angle and, once multiplied by the subject distance, a finest resolvable detail on the subject; the same physics fixes the Airy disk's diameter $2.44\,\lambda N$ at the sensor, drawn to scale against a 4 µm pixel grid so you can see when the blur outgrows a pixel and resolution stops being the sensor's business. The focal length, f-number, and aperture diameter are linked by $N = f/D$, so moving any one drives the dependent one and the three can never disagree. Wavelength is fixed at 550 nm, mid-visible green. Interactive: set the lens and the subject distance and read both limits.
💡 Big lesson (L2.10) — the smaller the aperture, the more diffraction blurs

Counter to ray-optics intuition, a smaller aperture spreads light more: the diffraction blur (the Airy disk) grows as $\sim\!\lambda N$ with f-number, so stopping down past a point softens the image instead of sharpening it. The flip side is the rule behind every instrument that must resolve fine detail: only a large aperture can diffract little and resolve finely, which is exactly why microscopes and telescopes are built around large lenses and mirrors, and why a phone camera's tiny aperture hits a hard resolution wall it cannot pass. It is the optical cousin of "you can't sample your way past Nyquist."

This produces the photographer's sweet spot. Open the aperture wide and aberrations (the imperfections of real glass, deferred to the Optics part) dominate, softening the image. Stop the aperture far down and diffraction dominates, softening it again. Somewhere in between, typically a couple of stops down from wide open, the two effects are jointly minimized and the lens is at its sharpest. "Stopping down too far softens the image" is not a defect of cheap lenses; it is physics, and the trade-off is made quantitative with the modulation transfer function in the Optics part.

fig-optics-bench
Figure 2.1.49 (reproduced). A build-it-yourself optical bench. Interactive: drop light sources and optical elements onto the bench: generators (from a single wavelength up to full daylight spectra), lenses, prisms, glass disks, mirrors, apertures, beam splitters, filters, spectral-BRDF objects, and sensors, then drag, rotate, scale, and tune each one. A single switch runs the same scene as recursive ray tracing (Snell refraction with dispersion, Fresnel reflection, and coatings) or as a live 2-D wave simulation (FDTD), or both at once, so you can watch a plane wave crowd and bend through a lens exactly as the rays converge. Every bench you build rides its own shareable link.

fig-diffraction-softening
Figure 2.1.50 (reproduced). Diffraction softening a photograph, one f-number at a time. Each pixel of the crop is treated as a sensor pixel of the chosen pitch, and the crop is convolved in linear light with the Airy pattern for that f-number and wavelength, drawn beside it on the same pixel grid with its first dark ring marked. The readout compares the lens's cutoff frequency 1/(λN) with the sensor's Nyquist 1/(2p): once the cutoff falls below Nyquist, stopping down further costs detail the sensor could otherwise have recorded. One wavelength stands for all three channels. Interactive: set the f-number, the wavelength and the pixel pitch, and change the photograph.

Pinhole image formation and linear perspective⧉

Photography with focal length: framing, magnification, and compression⧉

optional

The projection equation is also a working photographer's toolbox. Focal length sets the field of view, and choosing it is a creative decision: a wide lens (under about 30 mm on full frame) sweeps in a whole landscape and exaggerates near-far size differences; a standard lens (around 50 mm) roughly matches the framing of human attention; a telephoto (over about 100 mm) isolates a distant subject and flattens the scene.

The most useful (and most misunderstood) consequence concerns the difference between focal length and subject distance. Both change how large your subject appears, but they are not interchangeable, because they treat the background differently. Suppose you want a person's face to fill the same fraction of the frame. You can shoot wide and step close, or shoot long and step back. Either way the face is the same size, but stepping close with a wide lens makes the background recede dramatically and the nose loom, while stepping back with a telephoto pulls the background forward until it looks compressed, stacked up right behind the subject (Figure 2.2.22). Portrait photographers prize long lenses for exactly this flattering compression. The effect is not really "the lens compressing space"; it is the change in viewpoint (your distance to the subject) that sets the relative sizes of near and far, while the focal length merely chooses how much of that view to crop. Same subject size, different distance, different background: that is the lever.

💡 Big lesson (L2.16) — zooming in is not the same as moving closer

You can make a subject fill the same fraction of the frame either by zooming in or by stepping closer, and at that one depth the two give the identical magnification. But magnification falls off with distance, so everything at other depths behaves differently. Changing focal length rescales the whole projected image by a single factor (it is the pixel stage $K$, the "crop = zoom" lesson again), preserving every near-far size ratio; changing your distance rescales near and far by different factors, because each object's magnification depends on its own depth. Step close and the near looms while the far recedes; zoom from afar and the background stacks up "compressed" behind the subject. So relative near-far size (what we call perspective or compression) is set by viewpoint (distance), not by the lens; the focal length only chooses how much of that view to crop. The dolly zoom below is this lesson made vivid.

A related point about sensor size belongs here, even if it feels a touch early. A focal length only means a field of view relative to a sensor size: move the same lens to a smaller sensor and the sensor crops the projected image, narrowing the field of view, the "cropping = longer focal length" fact of Figure 2.2.11, now applied to whole sensors. This is why a focal length on a phone or an APS-C body is usually quoted as a full-frame "equivalent," and it is the perspective that small-sensor cameras give for a stated focal length. The sidebar collects the details.

💡 Big lesson (L2.17) — focal length does not specify the field of view without a sensor size, hence the 35 mm equivalent

The field-of-view-depends-on-sensor-size lesson (L2.12) carries straight over to a real lens: for a fixed focal length $f$, the field of view still follows $\text{FOV}=2\arctan(\text{sensor}/2f)$, so the same lens is wide-angle on a big sensor and telephoto on a small one: the smaller sensor simply crops the projected image into a narrower view. A focal length in millimeters is a real property of the lens, but on its own it does not specify the field of view: you have to name the sensor too. That is why focal lengths are quoted as a 35 mm- (full-frame-) equivalent: the focal length that would frame the same way on a $24\times36$ mm sensor. Concretely, a phone's main camera has an actual focal length of only about 6 mm, but on its tiny (~1/1.3-inch) sensor it frames like a 24–26 mm lens on full frame, so it is sold as "26 mm equivalent." The conversion is just the crop factor, full-frame diagonal ÷ sensor diagonal (≈ 7× for that phone), multiplying the real focal length.

[figure fig-focal-length-compression not built]
Figure 2.2.22 (reproduced). Focal length versus subject distance (background compression). The same subject is framed to the same size two ways: (left) a wide lens up close, and (right) a telephoto from far back. The subject matches, but the background differs dramatically: close-and-wide pushes the background away and enlarges near features; far-and-long compresses the background so it looms behind the subject. The relative sizes of near and far are set by viewpoint, not focal length.

The most vivid demonstration of the lever is the dolly zoom (the "Vertigo" or "trombone" shot): zoom in while dollying the camera back (or out while moving in) so the subject stays exactly the same size while the background visibly rushes in or pulls away behind it. As viewpoint distance changes and focal length compensates, the subject is pinned while the world behind it expands or contracts, the focal-length-vs-distance trade-off, animated (Figure 2.2.23).

fig-dolly-zoom-sim
Figure 2.2.23 (reproduced). The dolly zoom (interactive). A 3-D scene with a subject in front of a background; one control couples focal length and camera distance so the subject is always framed the same size. Slide it and the subject holds while the background dramatically expands (wide + close) or compresses (long + far), Hitchcock's Vertigo effect, and the cleanest proof that "compression" is a property of viewpoint, not of the lens. (3-D models generated with Meshy AI.)
Figure 1. community Upload your own dolly-zoom video to share with other readers.

Lens image formation⧉

Aperture and the f-number⧉

optional

For a compound lens, $D$ denotes the entrance-pupil diameter, the image of the aperture stop seen from object space. It need not equal the physical iris diameter. The simple cone argument below assumes a thin lens focused near infinity; pupil magnification and finite conjugates modify the close-focus relation.

We met the f-number $N = f/D$ a moment ago; it gets a section of its own, because it is one of the few numbers a photographer touches every time they shoot, and because why it is written as a ratio is instructive. The aperture is a physical thing, the diameter $D$ of the opening that admits light. Yet lenses are never marked in millimeters of opening; they are marked $f/2.8$, $f/5.6$, $f/11$, the focal length divided by that diameter. The slash is literal: $f/2.8$ means "the focal length, split into 2.8," an opening $D = f/2.8$ wide. Because $D$ sits in the denominator, the scale runs backwards from intuition, a small f-number is a wide opening (lots of light, shallow depth of field) and a large f-number is a narrow one. Once you internalize that the number is a divisor, "$f/1.4$ is bright and $f/22$ is dim" stops feeling backwards.

Why quote the opening as a fraction of focal length at all, rather than its raw diameter? Because the fraction, not the diameter, is what fixes the brightness of the image. The light delivered to a point on the sensor arrives as a cone: the rays that clear the aperture and reconverge there. The wider that cone, the more light. Its half-angle $\theta$ satisfies $\tan\theta = (D/2)/f = 1/(2N)$, so the cone depends only on the ratio $N$, never on the focal length by itself (Figure 2.3.14). Double the focal length and double the diameter, and the opening is physically twice as big, yet the cone, and therefore the brightness, is unchanged, because $N$ is unchanged. This is the whole reason the ratio exists: it makes a brightness setting that transfers. Set any lens to $f/2.8$, a $24$ mm or a $600$ mm, and each throws the same irradiance onto the sensor, even though the $600$ mm's opening is enormous by comparison. A raw diameter could never do that; the ratio nets out the focal length exactly. (The transfer is only mostly exact: vignetting darkens the corners, oblique rays fall off toward the frame edge, and at close focus the effective f-number increases to $N_\text{eff} = N(1+|m|)$ for the symmetric thin-lens model, with signed magnification $m$, the "bellows factor" behind macro's light loss. The geometry above is the clean first-order truth those are corrections to.)

fig-aperture-fnumber-cones
Figure 2.3.14 (reproduced). Why the f-number is written as a ratio, read off the light cone. Left: the same f-number gives the same cone, and hence the same brightness, at any focal length. A short lens (aperture $D$ at distance $f$) and a long lens (aperture $2D$ at distance $2f$) have the identical $N = f/D = 4$, so their converging cones share the very same half-angle $\tan\theta = 1/(2N)$; the long lens's opening is physically twice as wide yet pours no more light onto the sensor point, because only the ratio matters. Right: at a fixed focal length, opening up (a smaller f-number) widens the cone. The light collected follows the opening's area, $\propto D^2 \propto 1/N^2$, so $f/2, f/4, f/8$ pass $1, \tfrac14, \tfrac1{16}$ of the light; halving the area (one stop) takes a $\sqrt2$ step in $N$, which is the whole reason the aperture series climbs $f/2, 2.8, 4, 5.6, 8, \dots$

The same cone picture explains the aperture scale's numbers, $f/1.4, f/2, f/2.8, f/4, f/5.6, f/8, f/11, f/16$, a march in steps of $\sqrt2$. Light gathered goes as the opening's area, which goes as the diameter squared, so at a fixed focal length the light scales as $D^2 \propto (f/N)^2 \propto 1/N^2$. A stop, photography's unit, is a factor of two in light. To halve the light you must halve the area, and halving an area means shrinking the diameter by $\sqrt2$, i.e. multiplying $N$ by $\sqrt2$. That is the entire origin of the series: each full stop is one $\sqrt2$ step in f-number and one factor of two in light (Figure 5.2.4; and panel B of Figure 2.3.14). It is why the numbers look irregular but are really a clean geometric progression, and why aperture, shutter, and ISO can all be counted in the same stops (the exposure triangle of Chapter 5.2, Exposure and capture timing).

💡 Big lesson (L2.25) — the f-number is the aperture diameter as a fraction of the focal length

$N = f/D$: the f-number tells you the width of the opening measured in focal lengths, not in millimeters. $f/4$ means the opening is one quarter of the focal length across. Writing the aperture this way is what makes it a portable brightness setting: because the cone of light converging on each sensor point has half-angle $\tan\theta = 1/(2N)$, the ratio alone sets the image brightness, so the same f-number gives the same exposure on any lens, whatever its focal length or physical size. The denominator is why a small number is a big opening, and the area-goes-as-diameter-squared law ($\text{light}\propto 1/N^2$) is why the stop series climbs by $\sqrt2$.

Finally, a caveat that matters when light is precious. The f-number is a purely geometric quantity: it assumes a perfect, lossless lens and predicts the light such a lens would gather. Real glass is not lossless, every air-to-glass surface reflects a little, the elements absorb a little, and a complex zoom with twenty elements can quietly swallow up to a stop before any light reaches the sensor. The T-stop (transmission stop) folds those losses in, the f-number of an ideal lossless lens passing the same light, $T = N/\sqrt{\tau}$ for transmittance $\tau$, so a lens engraved $f/2.0$ may test at $T/2.3$. For still photographs, through-the-lens metering often compensates for transmission loss, but the difference still matters when comparing photon collection; cinematographers, who must intercut shots from different lenses at a matched brightness, buy lenses marked in T-stops. The full treatment, and why it matters for metering, is in Chapter 5.2, Exposure and capture timing (f-stops versus T-stops).

Depth of field⧉

in the book↗

Chapter 2.4, Image measurements as integrals over the plenoptic function cast every pixel as an integral over the plenoptic function; depth of field is what integrating over the aperture axis does. Lens image formation lets us gather far more of the plenoptic function's rays through the aperture than a pinhole would, while still forming a sharp image, but only for objects at the focus distance. Rays from objects nearer or farther do not converge to a single point on the sensor, and how much nearer or farther you can stray before the blur becomes objectionable is the depth of field (DoF). It is one of the photographer's main creative controls: a portrait with a melting, out-of-focus background, and a landscape crisp from the foreground flowers to the distant peak, are both choices about depth of field.

fig-dof-macro-extremes
Figure 2.5.1 (reproduced). Depth of field, the two extremes. The same 1:1 macro scene, the same 90 mm lens, the same spot, changing only the aperture: wide open ($f/2.8$) a razor-thin slice is sharp (shallow depth of field); stopped down ($f/22$) almost the whole receding row is sharp (deep depth of field). The aperture is depth of field's main control. Photographs by Frédo Durand.
Figure 2. community Upload your own photo showing a striking depth of field, very shallow or very deep, to share with other readers.

The circle of confusion⧉

in the book↗

Start with one out-of-focus point (Figure 2.5.3). A point at the focus distance sends a cone of rays through the lens that reconverges exactly on the sensor, a sharp point. A point too far away focuses in front of the sensor, so by the time its cone reaches the sensor it has opened back up into a small disk; a point too near focuses behind the sensor and likewise lands as a disk. That blur disk is the circle of confusion. A point still counts as "sharp" as long as its circle of confusion stays smaller than some acceptable diameter $c$, set by the sensor's resolution and how large you will view the print (for 35 mm film, $c$ is traditionally about 0.02 mm). The disk grows with the aperture (a wider opening, a fatter cone, a bigger disk) and with the point's distance from the focus plane (zero exactly at focus, growing both ways) (Figure 2.5.4).

💡 Big lesson (L2.27) — depth of field is set by a maximum acceptable circle of confusion

A defocused point never images as a point but as a blur disk: the circle of confusion. The depth of field is then defined as the range of distances over which that disk stays smaller than a chosen maximum $c$: inside the depth of field every point is blurred less than $c$, outside it more. The operative word is acceptable: $c$ is not a constant of nature but a judgement call that depends on the target application, the viewing distance, and the sensor (or print) resolution. A billboard read from across the street tolerates a huge $c$; a 100% crop on a 4K monitor almost none. Change the standard and the depth of field changes with it, even though the optics did not.

fig-circle-of-confusion
Figure 2.5.3 (reproduced). The circle of confusion. A point at the focus distance reconverges to a single point on the sensor (sharp). A point too far focuses in front of the sensor and a point too near focuses behind it, so each reaches the sensor as a small disk: the circle of confusion. A point is judged acceptably sharp while its disk stays under a tolerance diameter c. Depth of field widens as you stop down: a smaller aperture narrows the cone and lets more of the scene stay within the tolerance disk.
fig-defocus-vs-parameters
Figure 2.5.4 (reproduced). Defocus (circle of confusion) versus its parameters. Two panels sweep the blur-disk diameter against (left) aperture, where a wider opening (smaller N) gives a fatter cone and a bigger disk, and (right) the object's distance from the focus plane, zero exactly at focus, growing both ways (and faster in front than behind). Focal length and focus distance enter too. The circle of confusion is what the depth-of-field limits cap at the tolerance c.

The formula. All of this is one short calculation. Focus at distance $s$, so the lens (aperture diameter $D = f/N$) images the focus plane sharply onto the sensor. A point at some other distance $d$ would focus at a slightly different image distance, so its cone reaches the sensor still open, as a disk. Following that cone by similar triangles (the image-side construction of Figure 2.5.9) and eliminating the image distances with the thin-lens conjugate relation $1/f = 1/v + 1/d$ gives the circle of confusion as a function of the point's distance:

$$ c(d) = \frac{f^2\,\lvert s-d\rvert}{N\,d\,(s-f)}. $$

Everything qualitative reads straight off it: the blur is exactly zero at $d = s$ (the focus plane), grows with the focal length squared, grows as the aperture opens (small $N$), and grows with how far the point strays from focus. For a subject far compared with the focal length, $s - f \approx s$ and it simplifies to the approximate form

$$ c(d) \approx \frac{f^2\,\lvert s-d\rvert}{N\,d\,s}. $$

The relative error from replacing $s-f$ by $s$ is $f/s$; its size in pixels also depends on the blur diameter and pixel pitch. The approximation becomes less reliable where $s$ approaches $f$ (Big lesson L2.29). One special case matters here: a background at infinity ($d \to \infty$, so $\lvert s-d\rvert / d \to 1$) blurs to $c_\infty \approx f^2/(N s)$, which equals the tolerance $c$ exactly when $s$ is the hyperfocal distance $H = f^2/(N c)$. That coincidence, background-blur-equals-tolerance at $s = H$, is the tie we exploit below.

Depth of field versus depth of focus⧉

in the book↗

The circle of confusion has two faces, and they are easy to confuse (the names differ by one word). Depth of field is the object-side story we have been telling: with the sensor fixed, it is the range of subject distances that image acceptably sharply. Depth of focus is its image-side mirror: with the subject fixed, it is the range of sensor positions that keep that subject acceptably sharp, the mechanical tolerance on where the sensor (or film) is allowed to sit behind the lens. One lives out in the world in front of the lens; the other lives in millimeters, or rather microns, behind it.

They are conjugates, tied by the magnification. Near infinity focus in the thin-lens model, the total image-side tolerance is approximately $2Nc$ (the blur cone reaches the tolerance $c$ when the sensor is displaced by $\pm N c$ either way), with the finite-conjugate value instead using $N_{\rm eff}=N(1+|m|)$; project that image-side band back out through the lens and you get the object-side depth of field, which is why the latter stretches so dramatically with distance while the former barely moves. The practical weight is all on how small depth of focus is: at $f/2$ with $c \approx 0.02$ mm it is only about $\pm 0.04$ mm, so the sensor must be positioned, held flat, and kept parallel to that tolerance, and an autofocus system must place the focus to it. This is exactly why fast lenses demand tighter mechanical precision, why sensor flatness and film flatness matter, and why back- or front-focus of even a fraction of a millimeter is visible wide open but forgiven when stopped down (larger $N$ widens the depth of focus in proportion). Same geometry, two sides of the lens: depth of field is the photographer's concern, depth of focus the camera engineer's.

Choosing the maximum circle of confusion⧉

in the book↗

Depth-of-field calculations hang on one number, the tolerance $c$, and the big lesson above already warned that it is a judgement, not a constant. There are three different conventions for making that judgement, and they answer three different questions.

The classic version. Before digital, $c$ was pinned to a standard viewing scenario: enlarge the negative to a normal print (about 8×10 inches), view it at a comfortable distance (about 25–30 cm, somewhat shorter than that print's diagonal), and assume the eye resolves about 5 line-pairs per millimeter there. Trace that back through the enlargement and you get a fixed circle of confusion on the film or sensor, and the rule of thumb that survives is $c \approx \text{(sensor diagonal)}/1500$, about 0.02–0.03 mm for full-frame. Many engraved scales and depth-of-field tables use a fixed tolerance of this kind, though their numerical conventions differ. Its virtue is a single number per format; its vice is that it is wrong the moment you view the image any other way.

Pixel size. A digital-native alternative ignores viewing entirely and sets $c$ to a small multiple of the pixel pitch, often just one or two pixels. This is the right tolerance when the file itself is the product, judged at 100% on a monitor, or fed to a matching or reconstruction algorithm: subpixel blur can still change sampled edge profiles and contrast, so the chosen multiple remains a tolerance rather than a strict visibility boundary. It ties depth of field to the sensor's resolution rather than to any print.

Different display conditions. Both of the above are special cases of the only definition that is really true: $c$ is set by whatever blur is just too small to see in the final image, as it is actually viewed. A billboard read from across the street, a phone at arm's length, and a 100% crop on a 4K monitor differ by orders of magnitude in the tolerance they allow, from the same negative. The clean way to compute it is to work in the viewing geometry directly. The eye resolves about one arcminute; a blur on the display that subtends less than that is invisible. So from the display size, the viewing distance, and the image's pixel count you can read off the largest circle of confusion that still looks sharp, in image pixels or as a fraction of the frame, with the classic $\text{diagonal}/1500$ falling out as the one frozen standard (Figure 2.5.5). Set $c$ from your output, not from a table built for someone else's print.

fig-max-coc-calculator
Figure 2.5.5 (reproduced). The acceptable circle of confusion, from the viewing conditions, interactive. Depth of field is set by a tolerance $c$, the largest blur still judged sharp, and $c$ is a property of how the picture is viewed, not of the lens. The eye resolves about 1 arcminute; a blur on the display smaller than that is invisible. Set the display size, image resolution, and viewing distance, and the calculator returns the largest circle of confusion that still looks sharp, in image pixels and as a percent of the frame, floored at one pixel (the image carries no finer detail). A billboard tolerates a huge $c$; a 100% crop on a monitor almost none. The classic $\text{diagonal}/1500$ still-camera number is shown as a cross-check: it is exactly this calculation frozen at one standard, a normal print viewed at its own diagonal.

The double cone, and the near and far limits⧉

in the book↗

The simplest picture lives in object space: a double cone in front of the lens, its waist sitting on the focus plane, whose width at any depth is the blur that a point there would produce (Figure 2.5.7). Depth of field is the range of object distances whose circle of confusion stays within $c$, bounded by a near limit (closest still-sharp distance) and a far limit (farthest). The derivation is the same similar-triangles move as above, now solved the other way: take the circle-of-confusion formula, set $c(d) = c$, and solve for the object distance $d$. Split the absolute value into the near and far cases; each gives a linear equation in $d$, yielding the two limits (Figure 2.5.7, Figure 2.5.8, and Figure 2.5.9). Written with the hyperfocal distance $H = f^2/(N c) + f$ they take their standard compact form

$$ D_n = \frac{s\,(H-f)}{H + s - 2f}, \qquad D_f = \frac{s\,(H-f)}{H - s}, $$

with $D_f = \infty$ as soon as $s \ge H$: the far limit has run off to infinity, which is exactly what singles $H$ out. The total depth of field is $D_f - D_n$. Dropping the small $-f$ and $-2f$ terms (the same $s \gg f$ assumption) tidies these to

$$ D_n \approx \frac{sH}{H+s}, \qquad D_f \approx \frac{sH}{H-s}, \qquad \text{DoF} \approx \frac{2 H s^2}{H^2 - s^2}, $$

and one further step, for a subject much closer than the hyperfocal distance ($s \ll H$), collapses the total to the memorable scaling of the next lesson, $\text{DoF} \approx 2 N c\,s^2/f^2$. That last form is the one to carry around, and also the most approximate: it assumes both $s \gg f$ and $s \ll H$, so it is faithful across the everyday portrait-to-landscape middle and wrong at both ends, collapsing too fast in macro and, more visibly, missing the runaway to infinity as $s$ approaches $H$. The exact limits and their approximations are plotted together in Figure 2.5.11: the curves lie on top of each other across the ordinary range and split apart precisely where the assumptions fail. One caveat the tidy formulas hide is that the depth of field is asymmetric, with more sharp depth behind the focus plane than in front (the "roughly one third in front, two thirds behind" rule of thumb), and that asymmetry only grows with distance until the far limit reaches infinity. The qualitative results, though, are what you carry around, and they all point the same way: depth of field grows with a smaller aperture (larger $N$), a shorter focal length, and a greater focus distance (Figure 2.5.10). Stopping down is the photographer's main knob, but it costs light, so it forces a longer exposure or a higher ISO (more noise), and stopped down too far, diffraction softens everything (previous part). You can only push it so far.

Before calculators, all of this was engraved on the lens itself (Figure 2.5.6). The depth-of-field scale on a manual-focus barrel is a mechanical solution of exactly these near- and far-limit equations: two mirrored rows of f-numbers straddle the focus index, and for a chosen aperture its two marks bracket the near and far distances that will be sharp. Wider apertures give a narrow pair of marks (shallow depth), smaller apertures a wide pair, and setting the far mark on the infinity symbol is how you dial in the hyperfocal distance of the next section by hand.

fig-dof-scale-lens
Figure 2.5.6 (reproduced). The depth-of-field scale on a lens barrel. Around the focus-distance index sit two mirrored rows of f-numbers. Set the focus distance, then for any f-number read the near and far limits of sharpness straight off: the distances lying between its two marks are in focus. It is the near/far double-cone limits made into a mechanical calculator: wider apertures give a narrow pair of marks, smaller apertures a wide one, and aligning the far mark on infinity sets the hyperfocal distance. (Nikon 28 mm f/2.8.)
💡 Big lesson (L2.28) — depth of field scales linearly with f-number, quadratically with distance, inverse-quadratically with focal length

Away from the macro range (subject much closer than the hyperfocal distance), the total depth of field follows a clean scaling, $\text{DoF}\approx \dfrac{2\,N\,c\,s^2}{f^2}$: it grows linearly with the f-number $N$ (stop down for more), quadratically with the focusing distance $s$ (step back and it balloons), and inversely with the square of the focal length $f$ (wider for more, longer for less). These three exponents explain at a glance why a phone (tiny $f$) keeps almost everything sharp, why close focus annihilates depth of field, and why "I need more in focus" always reduces to stop down, back up, or go wider.

💡 Big lesson (L2.29) — many approximations break in the macro regime

The convenient first-order results of this chapter (the depth-of-field scaling just above, the framing shortcut "magnification $\approx f/\text{distance}$", even the bare f-number as a stand-in for image brightness) all quietly assume the subject is far compared with the focal length. Up close (macro, at magnifications near or past 1:1) they break. The pupil magnification stops being 1, the effective f-number grows as $N(1+m)$ so you lose real light, the working distance shrinks toward the front element, and the depth of field collapses to millimeters. In the macro regime you must drop the shortcuts and return to the exact conjugate geometry (and, often, to focus stacking). It is a good reflex to ask of any optics approximation: does this still hold when the subject is this close?

fig-dof-double-cone
Figure 2.5.7 (reproduced). Defocus as a double cone (object space). In front of the lens, the in-focus plane is the waist of a double cone whose width at any depth is the blur that a point there would produce. It gives the circle of confusion for one scene point; the cone widens with aperture. The depth of field is the band around the waist where the cone stays narrower than the tolerance c.
fig-depth-of-field
Figure 2.5.8 (reproduced). The near and far limits of depth of field. Each scene point's cone is carried to the sensor; the near-limit object focuses behind the sensor and the far-limit object in front of it, each producing a circle of confusion just equal to the tolerance c. The band between them is the depth of field, slightly asymmetric, with more depth behind the focus plane than in front. (Vertical scale exaggerated.)
fig-dof-derivation-near
Figure 2.5.9 (reproduced). The near (front) limit by similar triangles. Image-side construction: a near-limit object images behind the sensor; the converging cone from the aperture D crosses the sensor in a disk of diameter c. The similar triangles relating D, the image-side geometry, and c (with 1/f = 1/u + 1/v) fix the nearest acceptably-sharp object distance.
fig-dof-vs-parameters
Figure 2.5.10 (reproduced). Depth of field versus its three controls. Three panels plot the paraxial near/far limits against aperture (larger N → more DoF), focal length (shorter → more DoF), and focus distance (farther → more DoF). The same panels show the hyperfocal distance H = f²/(N·c) emerging as the focus setting beyond which the far limit runs to infinity.
fig-dof-approx-vs-exact
Figure 2.5.11 (reproduced). Exact formulas versus their approximations, interactive. Set the focal length, f-number, acceptable circle of confusion, and sensor size, then read the two panels. Left: the circle of confusion $c(d)$ against object distance, the exact $f^2|s-d|/(N d(s-f))$ drawn against the far-subject approximation that drops the $-f$; the two overlie each other for a normal subject and separate only as the focus distance is pushed into the macro range. Right: the total depth of field against focus distance $s$, the exact $D_f - D_n$ against the memorable $2Ncs^2/f^2$ scaling; they track across the everyday range and split apart as $s$ nears the hyperfocal distance $H$ (marked), where the exact depth of field runs to infinity while the approximation keeps climbing as a mere parabola. A quantitative companion to the "know when your approximation breaks" lesson.
fig-dof-parameter-grid
Figure 2.5.12 (reproduced). Depth of field versus all its parameters, interactive. The same scene shot across the aperture ($f/2$, $f/4$, $f/8$, $f/16$) and two geometric factors, the focal length (50 mm → 100 mm) and the subject distance (≈0.5 m → ≈1 m). A button pivots which factor runs along the columns versus the rows, and clicking any frame enlarges it below. Wider aperture, longer lens, and closer subject all shrink the depth of field (and throw the background further out of focus); a narrower aperture, wider lens, or more distance deepens it. Parameters from EXIF (distances approximate). Photographs by Frédo Durand.

Hyperfocal distance⧉

in the book↗

There is one focus setting that wrings the maximum depth of field out of a lens. Focus at the hyperfocal distance

$$ H = \frac{f^2}{N\,c}+f, $$

and everything from $H/2$ all the way to infinity falls within the tolerance $c$ (Figure 2.5.13). This uses the exact thin-lens hyperfocal distance; $H\approx f^2/(Nc)$ is the usual distant-subject approximation. This is the landscape photographer's trick (Ansel Adams used it constantly): focusing at infinity instead wastes the whole sharp zone between $H/2$ and $H$, whereas focusing at $H$ buys it back for free.

This is also the principle behind fixed-focus cameras, which have no focusing mechanism at all: the lens is simply glued at (or just beyond) the hyperfocal distance so that everything from $H/2$ to infinity is acceptably sharp. Because $H = f^2/(Nc)$ shrinks with the square of the focal length, this is easy when $f$ is tiny, which is exactly why it works so well for the short focal lengths of disposable cameras, webcams, doorbell and security cameras, and the ultra-wide modules on phones, and why some wide camera modules can use fixed focus, while closer focusing and longer-focal-length designs often need autofocus. The cost is that you can never throw the background out of focus or focus closer than $H/2$; fixed focus trades away near-subject sharpness and selective focus for a camera with no moving parts.

💡 Big lesson (L2.30) — focus at the hyperfocal distance and everything from half it to infinity is sharp

There is a single focus setting that extracts the maximum depth of field from a lens: the hyperfocal distance $H = f^2/(N c)$. Focus there and the far limit runs all the way to infinity while the near limit sits at exactly $H/2$, so the entire scene from $H/2$ to the horizon falls inside the acceptable circle of confusion. Focusing at infinity instead throws away the whole sharp zone between $H/2$ and $H$ for nothing. It is the landscape-and-street photographer's standard move for front-to-back sharpness, and the basis of zone focusing (pre-set the focus, shoot without refocusing).

fig-hyperfocal
Figure 2.5.13 (reproduced). Hyperfocal distance. Focusing at H = f²/(N·c) makes everything from H/2 to infinity acceptably sharp, the focus setting that maximizes depth of field. Focusing at infinity instead (top) leaves the near zone H/2…H blurred and wastes it; focusing at H (bottom) reclaims it. The landscape photographer's standard move for front-to-back sharpness.

The surprising invariance⧉

in the book↗

The practical conclusion is that a longer focal length does not, by itself, reduce depth of field when framing and f-number are held fixed. "Telephoto lenses have shallow depth of field" is not really true as stated. For a fixed framing (you keep the subject the same size in the frame) and a fixed f-number, the depth of field in object space is essentially independent of focal length (Figure 2.5.14). Switch from a 28 mm to a 100 mm lens and, to keep the subject the same size, you must step back; stepping back deepens the depth of field by exactly as much as the longer focal length shrinks it, and the larger physical aperture of the long lens (same f-number $N = f/D$ means $D$ grew with $f$) cancels the rest. They compensate to first order near the focus plane; finite depth-of-field limits need not coincide exactly. So shallow depth of field is really about magnification (how large the subject is on the sensor), not focal length per se.

💡 Big lesson (L2.31) — near the subject, depth of field follows magnification; in the far background, the long lens wins

Two different questions get confused. Near the plane of focus, at equal magnification and equal f-number, the depth of field is essentially independent of focal length: stepping back to hold the framing gives back exactly what the longer lens took. In the distant background, the longer lens does defocus more, because what blurs a far object is the physical aperture diameter $D=f/N$, which grows with focal length at a fixed f-number. So "telephotos have shallow depth of field" is wrong about the subject and right about the background.

This is genuinely useful: for macro work, where depth of field is precious, you can change your working distance (back off to make room for lights, say) with approximately the same near-focus depth of field in the thin-lens model, as long as you re-frame to the same magnification. The background does still look more blurred through the long lens, but that is because the long lens magnifies the already-out-of-focus background disks, not because the depth-of-field band changed.

fig-dof-same-framing
Figure 2.5.14 (reproduced). Same framing + same f-number → same depth of field. A subject is shot at 28 mm up close and at 100 mm from farther back, framed to the same size and at the same f-number. The band of acceptably sharp depth around the subject is the same in both: the longer focal length is exactly canceled by the greater distance (and the larger physical aperture). Shallow depth of field comes from magnification, not focal length. (The distant background is more blurred in the telephoto shot because it is magnified more, a separate effect.)
fig-focus-magnification
Figure 2.5.15 (reproduced). Refocusing changes the projected size ("focus breathing"). The same 90 mm lens on the same scene, changed only by turning the focus ring: left, focused on the near figures; right, on the far ones. Notice that the projection of the subject is a different size even though the focal length hasn't changed: refocusing moves the image plane, so the magnification (and the field of view) drifts. It is why focus stacking and focus pulls need care. And this drift persists despite the lens maker fighting it: a compound lens can be built to shift its own effective focal length slightly as it focuses (internal-focusing trickery a single element could not manage), which curbs the breathing but does not erase it. The diagram below traces the geometry. Photographs by Frédo Durand.
fig-focus-fov
Figure 2.5.16 (reproduced). The geometry of focus breathing. A thin lens of fixed focal length $f$ images a row of colored disks (the Lego figures) onto a sensor; to focus on a disk at distance $o$ the sensor slides to that disk's image distance $i = f\,o/(o-f)$: focusing moves the sensor, not the lens. The shaded double cone is the field of view, the rays from the two sensor edges through the center of the lens continued into the scene. Drag the focus (or click a disk) and watch the sensor slide: the cone opens or closes and the projection of every disk grows or shrinks, even though the focal length never changes. Thin-lens model.

All of this (the three controls, the circle of confusion, the near/far limits, the hyperfocal distance, and the constant-magnification invariance) is easiest to feel by driving it yourself (Figure 2.5.17). It is the same physics as the 3-D macro simulator at the end of this chapter, drawn as a single 2-D ray diagram plus a plot, so the numbers are right there: slide the focal length, f-number, and subject distance and watch the near/far limits and $H$ move; then tick constant magnification and watch the depth of field go nearly flat against focal length, the invariance of the previous paragraph, made literal.

fig-dof-raydiagram
Figure 2.5.17 (reproduced). Depth of field as a 2-D thin-lens ray diagram, interactive. Set focal length, f-number, subject distance, the acceptable circle of confusion c (readable as a fraction of the image, in percent, pixels, or millimeters), and the sensor size. The diagram shows the focused cone converging to a point on the sensor while a background point reconverges in front of it and spreads into a blur disk; the plot below shows the blur-disk diameter versus object distance, with the c tolerance and the shaded near–far depth-of-field window, and the focus and hyperfocal distances marked. The readout gives H, the near/far limits, the total DoF, the magnification, and the circle of confusion of a background at infinity. Tick "constant magnification" to instead plot total DoF against focal length at fixed framing: a nearly flat line, the depth-of-field-is-about-magnification lesson made quantitative. A lighter companion to the 3-D depth-of-field simulator.

The invariance is sharpest when you plot two focal lengths at once (Figure 2.5.18). Fix the magnification (the same framing of the subject) and draw the circle of confusion against distance from the focus plane for a short and a long lens: at focus the two curves have the same one-sided slopes, so the depth of field is the same, but far behind the subject the long lens climbs to a much higher plateau. That plateau is the background blur, and it equals the aperture diameter times the magnification ($f\,m/N$), so it grows with focal length. Depth of field is set by magnification; how hard a distant background is thrown out of focus is set by the aperture diameter. The two facts live in the same picture.

fig-coc-same-magnification
Figure 2.5.18 (reproduced). Two focal lengths at the same magnification, interactive. Pick two focal lengths and hold the magnification fixed (or set the subject distance for the first lens and let the second match its framing); the circle of confusion is plotted against distance from the focus plane for both. Near the focus the curves overlap, the depth of field is essentially identical, the invariance made literal (a zoomed panel on the right, its source region marked by a rectangle, magnifies where the curves cross the max-CoC threshold so that near-equality is visible directly), while far behind the subject the longer lens plateaus much higher: its background blur is $f\,m/N$ (aperture diameter times magnification), so it scales with focal length. The lesson in one figure: depth of field follows magnification, background blur follows the aperture diameter.

Background blur beyond the focus plane⧉

in the book↗

The invariance is a statement about the near neighborhood of the focus plane: hold the framing and two focal lengths give the same depth of field. Push past that neighborhood, out toward the background, and the two lenses part company. The circle of confusion keeps growing with distance from the focus plane, and it grows faster for the longer lens, until it saturates at a ceiling set by a subject infinitely far away. That ceiling is the background blur, the quantity that decides how cleanly a portrait separates from its backdrop.

The infinity blur. Take the circle of confusion of the previous sections and let the object recede to infinity. With the subject focused at $s$,

$$ c(d) = \frac{f^2\,\lvert d-s\rvert}{N\,d\,(s-f)} \;\xrightarrow{\,d\to\infty\,}\; c_\infty = \frac{f^2}{N\,(s-f)}, $$

because $\lvert d-s\rvert / d \to 1$. This is the on-sensor blur diameter of a point infinitely far behind the subject. It has a clean reading once you substitute the aperture diameter $D=f/N$ and the on-axis magnification $m=f/(s-f)$:

$$ c_\infty = \frac{f^2}{N\,(s-f)} = \frac{f}{N}\cdot\frac{f}{s-f} = D\,m, $$

the aperture diameter times the magnification, the same $f\,m/N$ plateau the two-focal-length figure climbed to. At a fixed framing (fixed $m$) it scales with the physical aperture $D$, which is the sensor-size argument of the next section: a bigger lens throws a background further out of focus. At a fixed subject distance $s$, which is what a photographer swapping lenses on the spot actually holds, it scales as $f^2/(s-f)$, close to $f^2$ for an ordinary subject, so doubling the focal length roughly quadruples the background blur. That is the real content of "telephotos blur the background": it is a claim about the background, not about the depth of field, which the previous section showed is unchanged at fixed framing. A big super-telephoto, with its large physical aperture, is where this reaches its extreme (Figure 2.5.19): a distant background collapses into a smooth wash, isolating the subject completely.

fig-lava-heron-bokeh
Figure 2.5.19 (reproduced). Subject separation from a large aperture. A lava heron photographed at 700 mm (a 500 mm super-telephoto with a 1.4× teleconverter) at $f/7.1$ on a Canon EOS-1D Mark II: the bird is sharp, but the distant background dissolves into a smooth wash of green and out-of-focus highlights. This is the infinity-blur plateau $c_\infty = D\,m$ made visible: even at $f/7.1$ the physical aperture is $D = f/N = 700/7.1 \approx 100$ mm across, so a far point is smeared over a big fraction of the frame and the subject stands cleanly clear of its surroundings. The separation is set by the aperture diameter (and the magnification), not by the depth of field, which stays shallow right at the bird.

To compare $c_\infty$ against a tolerance, divide by the sensor width $w$ for a fraction of the frame, or multiply by the horizontal pixel count $n_\text{px}$ for pixels:

$$ \frac{c_\infty}{w} = \frac{f^2}{N\,(s-f)\,w}, \qquad c_\infty^{\,\text{px}} = \frac{f^2\,n_\text{px}}{N\,(s-f)\,w}. $$

The background blur is thus fixed by five numbers: the f-number, the focal length, the focus distance, the sensor size, and (for pixels) the resolution. Figure 2.5.20 plots it against focal length at a chosen f-number and distance, and the near-$f^2$ climb is the whole story.

fig-background-blur-vs-focal-length
Figure 2.5.20 (reproduced). Background blur versus focal length, interactive. A point at infinity blurs on the sensor to $c_\infty = f^2/(N(s-f))$, equivalently the aperture diameter times the magnification ($D\,m$). Fix the f-number and the subject distance and sweep the focal length: at fixed distance the blur climbs roughly as $f^2$, so a long lens throws a distant background far out of focus while a wide lens keeps it legible, even though (previous section) the near-focus depth of field is the same at equal framing. Choose the axis units (microns, percent of the frame, or pixels for a given resolution and sensor); a marker reads the blur at one focal length, with the aperture diameter and magnification alongside.
[figure fig-background-blur-focal-length-photos not built]
Figure 2.5.21 (reproduced). Background blur grows with focal length, at fixed framing. The same subject shot at a wide, a normal, and a telephoto focal length, each time stepping back to keep the subject the same size in the frame. The subject is equally sharp in all three (the depth of field is the same, the invariance of the previous section), but the background dissolves progressively: the long lens, with its larger physical aperture, smears a distant point across a far larger fraction of the frame. This is subject separation, and it is set by the aperture diameter, not by the depth of field. Photographs by Frédo Durand.

The whole field. The infinity blur is one boundary case. Hold the f-number and the focus distance and the full circle of confusion is a function of two variables at once, the focal length and the signed distance from the focus plane $\Delta = d - s$ (background positive, foreground negative):

$$ c(f,\Delta) = \frac{f^2\,\lvert\Delta\rvert}{N\,(s+\Delta)\,(s-f)}. $$

Figure 2.5.22 draws this field, as a color map or a spinnable 3-D surface. Two features carry the depth-of-field story in one image. Along $\Delta=0$ runs a valley of zero blur, the focus plane. Its slope, the rate at which blur opens up as you leave focus, is $\lvert\partial c/\partial\Delta\rvert$ at $\Delta=0$, which reduces to

$$ \left.\frac{\partial c}{\partial \Delta}\right|_{\Delta \to 0^+} = \frac{f^2}{N\,s\,(s-f)} = \frac{m^2}{N\,(m+1)}, $$

depending only on the magnification and the f-number, not on the focal length. That is the invariance, made into a tangent: at a given framing every focal length shares the same ridge slope at the valley, so the same near-focus depth of field. Away from focus the surface climbs, and it climbs steeper for larger $f$, so the curves for two focal lengths, tangent at the valley, separate as $\Delta$ grows and level off at the infinity ceiling $c_\infty = f^2/(N(s-f))$ derived above. Depth of field lives in the tangent; background blur lives in the plateau; the same surface shows both.

fig-coc-field-f-defocus
Figure 2.5.22 (reproduced). The circle of confusion as a field over focal length and defocus, interactive. One picture of the full formula $c(f,\Delta) = f^2\lvert\Delta\rvert / (N(s+\Delta)(s-f))$, with $\Delta$ the signed distance from the focus plane, at a chosen focus distance and f-number. Switch between a 2-D color map and a 3-D height field you can spin (azimuth). The valley along $\Delta=0$ is the focus plane, whose tangent (the near-focus slope $m^2/(N(m+1))$) is shared by every focal length at a fixed framing: the depth-of-field invariance. Climb the focal-length axis and the walls steepen, so a distant background blurs far more through a long lens, leveling off at the infinity ceiling $f^2/(N(s-f))$. The sensor sets the percent/pixel units on the color scale.

The calculator. Figure 2.5.23 gathers all of this (the exact circle of confusion and its far-subject approximation, the near and far limits, the hyperfocal distance, the infinity blur, and the tolerance that turns a blur into a depth of field) into one working tool. Set the focal length (as a 35 mm-equivalent, so the framing is held fixed as you change sensors), the f-number, the focus distance, the sensor, and your acceptable circle of confusion in pixels or percent of the frame. It draws the circle of confusion against distance, marks the infinity blur and the tolerances a single pixel, a phone, and the eye's acuity each imply, and reads the depth of field off at your setting and at typical phone and 16-inch-laptop viewing, giving both the exact thin-lens value and the $2Ncs^2/f^2$ approximation side by side. The tangent near focus is where the depth-of-field invariance lives; the growth beyond it, out to the infinity plateau, is the background blur. It is the calculator form of the one idea this chapter keeps returning to: the depth of field is only as real as the maximum circle of confusion you are willing to accept, and that number comes from how the picture will be seen.

fig-dof-calculator
Figure 2.5.23 (reproduced). A full depth-of-field calculator, interactive. Inputs: focal length (with a 35 mm-equivalent toggle, on by default, so framing is fixed across sensors), f-number, focus distance, sensor size, and the maximum circle of confusion in pixels or percent of image width. It plots the circle of confusion versus object distance as both the exact thin-lens curve and its far-subject approximation, with a zoom inset on the depth-of-field region, draws the circle-of-confusion-at-infinity asymptote and horizontal tolerance lines for one pixel, typical phone viewing, and human acuity (a close print), and tabulates the depth of field, at your tolerance and at phone and 16-inch-laptop viewing conditions, computed both exactly and by the $2Ncs^2/f^2$ approximation. Pixels assume a 24 MP frame.

Defocus is not a blur of the image⧉

in the book↗

It is tempting to think you could fake shallow depth of field by simply blurring a sharp photo, convolving it with a disk. You cannot, and the reason matters (Figure 2.5.24). The circle of confusion depends on each point's scene depth, not on its position in the image, so the blur is spatially varying in a way tied to 3D structure rather than pixel coordinates. Worse, at depth discontinuities (the edge of a foreground object against a far background) occlusion comes into play: the blurred foreground should bleed over the background, and the background that the foreground hides should partly show through the foreground's blur, neither of which a flat 2D blur can do. Depth of field is not a convolution of the image. This is exactly why naive "portrait mode" fakes look wrong at hair and edges, and why depth-aware and light-field methods (Advanced part), which know each pixel's depth, or capture the rays directly, do so much better.

fig-dof-depth-dependent
Figure 2.5.24 (reproduced). Why defocus is not an image convolution. Left, a spatially-invariant disk blur of a flat image: every pixel blurred the same, ignoring depth. Right, true defocus: the blur radius is set by each point's scene depth, and at the foreground–background boundary occlusion matters: the foreground's blur bleeds over the background and the background shows through. A 2D convolution cannot reproduce either, which is why depth-unaware fakes fail at edges.

Sensor size scales depth of field⧉

in the book↗

Finally, a fact that explains your phone. Shrink the sensor while keeping the field of view (FOV), and both the circle of confusion $c$ and the physical aperture $D$ shrink in proportion, so depth of field grows linearly as the sensor shrinks. Short-focal-length phone cameras often have a large depth of field at ordinary subject distances, motivating synthetic background blur in portrait mode. The same fact makes macro photography easier on small sensors: at matched framing and viewing tolerance, a smaller sensor can offer greater depth of field at the same f-number; minimum focus still depends on lens design, except for diffraction, since shrinking the camera does not shrink the wavelength of light.

The same story told from the image side is the one a phone designer feels most acutely. For a subject held at a fixed framing, the out-of-focus blur of the background (measured as a fraction of the frame) is proportional to the lens's physical aperture diameter $D = f/N$. Scale the whole camera down by the crop factor (sensor and focal length shrink together, the f-number $N$ held fixed) and $D$ shrinks by that same factor, so the background blur shrinks linearly with the sensor. For an illustrative linear crop factor of seven, $f/1.8$ gives roughly the depth-of-field behavior of full frame at $f/12.6$, at matched viewpoint, framing and output tolerance away from macro. Phone sensor sizes vary, and phones can produce genuine optical background blur for close subjects. Portrait mode extends that blur beyond what the available aperture provides.

💡 Big lesson (L2.32) — in image space, defocus blur shrinks linearly with the sensor

Hold the framing and the f-number fixed and scale the camera down: the defocus blur of the background, as a fraction of the frame, shrinks linearly with the sensor size, because it tracks the lens's physical aperture diameter $D=f/N$ and $f$ shrinks with the sensor. So shallow depth of field is a privilege of physically large apertures (a big sensor with a big lens) and a small sensor cannot fake it optically. This is why phones have deep depth of field and must compute fake background blur (portrait mode, a later chapter): the tiny sensor shrinks every blur disk toward nothing. It is the image-space twin of "small sensor → more depth of field" above.

A revealing optical workaround predates the computational one: relay optics. Place a physically large lens out front to cast a large, genuinely shallow-depth-of-field image onto a diffusing ground-glass screen, then re-photograph that screen with a small-sensor camera through a macro/relay lens. The small camera now inherits the big lens's shallow depth of field (and its wide field of view), paying only in lost light, a little softness, and the screen's faint grain. This is precisely how 35 mm lens adapters (such as the Letus, Redrock M2, and Brevis units) let early small-sensor camcorders borrow a large-format "cinematic" look before big-sensor video existed; the same relay trick lives on in view-camera ground glass and in microscope-to-camera couplings.

fig-depth-of-field-sim
Figure 2.5.25 (reproduced). Try it yourself (web edition). A live macro depth-of-field simulator with three linked panels driven by one optics model: a to-scale thin-lens diagram, a lens-supersampled 3D photo with real bokeh, and a circle-of-confusion-versus-distance plot. Set the focal length, f-number, sensor size, focus distance, and subject–background gap, and choose a bug (beetle, bee, or ladybug) over a flower. The macro lesson is immediate: the in-focus slice is so thin that focus on the front of the face leaves the rest of the body, the antennae, and the background all dissolved. In the printed edition this figure stands in as a screenshot. The bug and flower are 3D models generated with Meshy AI.

Defocus is integration over the aperture dimension of the plenoptic function⧉

optional

One picture ties all of this back to the plenoptic function of Chapter 2.4, Image measurements as integrals over the plenoptic function. Plot the light inside the camera as a two-dimensional ray-space diagram: the horizontal axis is position across the sensor $x$, the vertical axis is position across the aperture $u$ (which ray, through which part of the lens). A scene point emits a fan of rays, and in the $x$-$u$ diagram that fan is a straight line. Its slope is the point's depth: on the focal plane the line is vertical (every ray lands at the same $x$); off it, slanted (rays land at different $x$, the spread that becomes the circle of confusion).

A photograph integrates over the aperture: it sums every ray at a given $x$, collapsing the $u$ axis. A vertical line collapses to a sharp point; a slanted line smears across a range of $x$, and that width is the blur. Depth of field is then a statement about slopes: the band of depths whose lines stay close enough to vertical that the smear remains within the chosen circle-of-confusion tolerance. Stopping down shortens the $u$ axis, so even a slanted line collapses to a narrow smear, which is why a smaller aperture deepens the field. The next chapter runs the same picture for motion blur with time in place of the aperture; it is the Part 31, Light fields and plenoptic cameras seen head-on (Figure 2.5.26).

fig-dof-ray-space
Figure 2.5.26 (reproduced). The $(x, u)$ light field of a textured scene, and how the aperture integral blurs it. Left, a rotated top-down flatland scene: three colored disks (drag a center or the rim handle), a lens, and the sensor on the right where pixel $x$ lives. Each disk carries a pizza-slice texture, alternating dark and light wedges of its own color, and a slider sets the number of slices. Right, the plenoptic function as a grid of little squares, one per ray $(x, u)$, colored by the disk that ray lands on and by which slice of its surface it hits. Because a wider aperture looks at each point from a spread of directions, the texture shears across the $u$ axis; a disk's slope in the plane is its depth, vertical when it sits on the focus plane. Beside the plane is the recorded image, the plane integrated over the aperture band: the angular texture averages away, and the more sloped, defocused disks blur more than the in-focus one, which is depth of field. Two sliders pick one ray $(x, u)$, shown in the scene as a sensor-to-lens-to-scene ray and as a gold square in the plane; a toggle swaps the voxel squares for smooth bands. The next chapter's space-time figure is this same construction with time in place of the aperture.

Sensors: photosites, CCD vs CMOS⧉

The impact of sensor size⧉

optional

Sensor size is the quiet variable behind half the trade-offs in this book; this section gathers its consequences in one place. The headline number is the crop factor: the ratio of the full-frame diagonal ($43.3$ mm) to the sensor's own diagonal. Full frame is $1\times$ by definition; APS-C is about $1.5\times$, Micro Four Thirds $2\times$, a 1-inch compact $2.7\times$, and phone camera modules spanning a broad range of crop factors (smaller still for its ultrawide and tele modules). Almost everything below scales with that one factor.

fig-sensor-sizes
Figure 2.7.12 (reproduced). Sensor and film formats, to scale. The common digital sensor formats and a few film formats nested at a shared corner, so their relative areas are immediate: a phone's 1/2.3" chip is a postage stamp beside full frame, which is itself dwarfed by medium-format film. Because light gathered scales with area, these rectangles are, quite literally, a picture of the low-light and dynamic-range headroom each format buys. (Active image areas, in millimeters.)
fig-sensor-size-explorer
Figure 2.7.13 (reproduced). Sensor size and photosite size, together (interactive). Pick a standard format and a resolution; the figure draws that sensor to scale against the full-frame outline and magnifies the photosites it implies, with the pixel pitch in microns beside a ~2 µm human cone for scale. Two independent dials: the format sets total light, depth of field, and lens size (via the crop factor), while resolution dices that area into photosites whose pitch sets per-pixel light and where diffraction begins to bite. Push a phone sensor to 108–200 MP and its pixels shrink below a single cone (why phones bin pixels together and lean hard on denoising) while the same megapixels on full frame stay several microns wide and clean. (Pixel pitch = sensor width ÷ horizontal pixel count.) Interactive: choose sensor format and megapixels to see the sensor drawn to scale and its resulting photosite pitch against a human cone.

Field of view. A focal length frames differently on every sensor, because field of view depends on sensor size (L2.12, L2.17): the same lens is wide on a big sensor and telephoto on a small one. This is why focal lengths are quoted as a 35 mm equivalent $=$ actual focal length $\times$ crop factor (a 6 mm lens with a crop factor of 4.3 frames like about 26 mm). The flip side is "reach": a crop body turns a 300 mm lens into the framing of a 450 mm for free, handy for wildlife and sport, at the cost of the wide end.

fig-sensor-fov-rays
Figure 2.7.14 (reproduced). Why a bigger sensor sees wider, in rays. The chief rays from each sensor's top and bottom edge pass straight through the lens node and open into a cone whose half-angle is $\theta = \arctan\!\big((\text{sensor}/2)/f\big)$. At the very same focal length, a tall full-frame sensor subtends a wide cone (a wide field of view) while a short phone sensor subtends a narrow one (telephoto), which is exactly why a focal length does not fix the field of view until you also name the sensor.
fig-sensor-fov
Figure 2.7.15 (reproduced). Sensor size sets field of view (interactive). Click a to-scale sensor format (or drag the crop-factor slider) and set the focal length; the box on the reference scene shows the framing that sensor captures. Shrink the sensor at a fixed focal length and the view tightens toward telephoto, which is why lenses are quoted as a 35 mm equivalent, focal length $\times$ crop factor. Interactive: pick a sensor size and focal length to see the framing box tighten on a reference scene, with the 35 mm-equivalent focal length and horizontal field of view.

Depth of field. Shrinking the sensor deepens depth of field and shrinks the background blur in proportion L2.32: at fixed framing and f-number the out-of-focus blur tracks the physical aperture diameter, which scales with the sensor (the ray geometry is in Figure 2.7.17, below). Small sensors often give greater depth of field at ordinary subject distances, while close subjects can still produce optical background blur which is exactly why phones must synthesize shallow depth of field (portrait mode, a later chapter). For an illustrative crop factor of seven, $f/1.8$ corresponds approximately to full frame at $f/12.6$ for matched viewpoint, framing and final viewing tolerance outside macro.

fig-sensor-dof
Figure 2.7.16 (reproduced). Sensor size sets depth of field (interactive). Click a to-scale sensor format (or drag the crop-factor slider) and set the f-number; the subject stays sharp while the background bokeh grows with a bigger sensor and wider aperture and collapses on a small one. The readout gives the equivalent f-number, $N \times$ crop factor: a phone at $f/1.8$ has full-frame's $\approx f/12$ depth of field. Interactive: pick a sensor size and f-number to watch background blur grow with sensor size, with the equivalent f-number shown.

Light gathering: the real reason big sensors look better. At equal framing and equal f-number, a larger sensor collects more total light, because its aperture is physically larger (same $N=f/D$, but $f$, and hence $D$, are bigger). More photons means a higher signal-to-noise ratio L2.38 and more dynamic range: this, not pixel count, is why a full-frame photo looks cleaner than a phone photo of the same scene. The advantage is the total sensor area, almost independent of how finely that area is diced into pixels.

fig-sensor-aperture-rays
Figure 2.7.17 (reproduced). The physical aperture is what scales, in rays. The f-number $N=f/D$ fixes only the shape of the light cone. To frame a scene the same way on a bigger sensor you need a proportionally longer focal length $f$, so at the same f-number the physical aperture $D=f/N$ grows with the sensor: a full-frame camera at $f/2$ has a much wider entrance pupil than a phone at $f/2$. From every scene point it collects a wider cone of rays (more light, scaling with the pupil area and hence the sensor's area), and that same larger aperture is what shrinks the depth of field.
fig-sensor-light
Figure 2.7.18 (reproduced). Sensor size sets total light, noise, and dynamic range (interactive). Click a to-scale sensor format (or drag the crop-factor slider) and set the f-number; the swatch shows the noise you would get relative to a full-frame reference. Total light scales with the sensor's area ($\propto 1/c^2$) and the photon-noise-limited SNR with its linear size ($\propto 1/c$), so a full-frame sensor gathers several stops more light than a phone at the same framing and f-number. Interactive: pick a sensor size and f-number to see a noisy tonal swatch, the total light versus full frame, and the stops of SNR gained over a phone sensor.

What happens as pixels shrink in $x$ and $y$. Scale a sensor (or a pixel) down in the image plane and the photodiode shrinks with it, with two consequences. First, the full-well capacity (the most electrons a pixel can hold before it saturates) scales roughly with photosite area, so a smaller pixel clips its highlights sooner and carries less dynamic range. Second, the depth of the silicon does not shrink in step: it is set by how deep red light penetrates silicon (a few microns, regardless of pixel width), so very small pixels become awkward tall-and-thin wells with more cross-talk between neighbors and harder microlens focusing, part of why sub-micron pixels need back-side illumination and deep-trench isolation to work at all.

What else sensor size touches, the easy-to-forget list: diffraction (a smaller pixel meets the lens's Airy-disk limit sooner, so past a point more megapixels resolve nothing, and the diffraction-limited aperture arrives at a wider f-stop on a small sensor); lens size, weight, and cost (a bigger sensor demands physically bigger glass to cover it, the reason full-frame kits are large and expensive); rolling-shutter skew (readout time depends on row count, parallelism and circuit speed, rather than physical sensor area alone); and manufacturing cost and yield (silicon defects make large sensors disproportionately pricey: manufacturing cost need not scale linearly with area). Low-light reach, dynamic range, bokeh, lens bulk, and price all trace back to this one dial, which is why "what size is the sensor?" is usually the first question worth asking about any camera.

💡 Big lesson (L2.36) — sensor size is one dial behind field of view, depth of field, and light; the equivalences scale linearly with it, the light with its area

Almost every camera trade-off scales with the sensor's linear size, captured in the crop factor $c$ (full-frame diagonal $\div$ the sensor's). Three consequences, each with a different scaling:

  • Field of view: to match a framing, the equivalent focal length scales linearly, $f_{\text{eq}} = f \times c$ (L2.12, L2.17): a phone's $6$ mm lens frames like $\sim\!26$ mm.
  • Depth of field: at fixed framing and f-number the physical aperture diameter, and so the background blur, scale linearly with sensor size, so the equivalent f-number is $N_{\text{eq}} = N \times c$ L2.32: a phone at $f/1.8$ has full-frame's $f/12$ depth of field. Small sensors give deep, near-universal focus and little bokeh.
  • Light and noise: at equal framing and f-number the total light collected scales with sensor area ($\propto c^{2}$), so the photon count does too; photon-noise-limited SNR and dynamic range then scale with the linear dimension ($\sqrt{\text{area}}$, $\propto 1/c$) L2.38. This total-light advantage, not pixel count, is why a big sensor looks cleaner.

So the bookkeeping is: equivalent focal length and equivalent f-number are linear in sensor size; total light gathered is quadratic (its area); the SNR and dynamic-range benefit go as the linear dimension (the square root of area). One dial, three different exponents.

Where pixel pitch is heading. Pixel pitch does not just vary across cameras, it is diverging over time (Figure 2.7.19): big-camera pixels (full-frame, APS-C) have hovered around 4–8 µm for two decades, with higher resolution within a fixed format obtained by reducing pixel pitch, while phone pixels have been driven relentlessly down, now well below a micron (to about $0.6\,\mu$m on 200 MP sensors). This continued shrinking is why phones must bin pixels in low light (the quad-Bayer trick), and why it runs into hard physical floors: a sub-micron pixel approaches the diffraction-limited spot size of the lens (the Airy disk has a first-zero diameter of about $2.7\,\mu$m at $f/2$ and 550 nm), so finer sampling increasingly measures a diffraction-filtered image rather than proportionally more independent detail, while the tiny full-well capacity caps dynamic range.

fig-pixel-pitch-history
Figure 2.7.19 (reproduced). Photosite (pixel) pitch over two decades, by camera class. Big-camera pixels (full-frame, APS-C) have plateaued around 4–8 µm (more megapixels came mostly from larger sensors, not smaller pixels) while phone pixels have shrunk relentlessly, now below 1 µm (down to ~0.6 µm on 200 MP sensors). The dashed line marks the diffraction-limited Airy radius at $f$/2: once a pixel is that small, the lens can no longer resolve detail at the pixel scale, so the extra pixels mostly serve binning. Representative pixel pitches (sensor width ÷ horizontal pixel count) for landmark cameras and phone sensors.

Convolution⧉

Is imaging blur usually a shift-invariant convolution?⧉

optional

This whole chapter has modeled blur as a convolution, one kernel, applied identically everywhere. How often is that actually true of real camera blur? Usually it is not, and knowing where the model breaks tells you when the clean linear-shift-invariant (LSI) tools apply and when they do not.

Camera rotation produces a sequence of homographies for a static scene and fixed intrinsics. Pan and tilt resemble translation over a narrow field, but their displacements vary across a wide image; roll traces arcs about the principal point. Camera translation introduces depth dependence and parallax. See Whyte et al. 2011/2014 and Chapter 16.4, Blind deblurring.

Defocus depends on the difference between a point’s inverse depth and the focused plane’s inverse depth, as well as the aperture and lens geometry. It is zero at the focused plane, not proportional to inverse depth alone. Visibility at foreground/background boundaries requires a fuller model than blurring each region independently.

Lens aberrations can vary with field position, wavelength, aperture, and focus. Coma and field curvature are important off-axis effects; spherical aberration is present on axis too. Longitudinal chromatic aberration shifts focus with wavelength. Lateral chromatic aberration shifts image position or scale with wavelength and can often be reduced by calibrated per-channel warps, though each broad color channel still integrates wavelength-dependent effects. See Chapter 22.1, Aberrations and optical challenges and Chapter 22.2, Aberrations correction.

Motion blur. Object motion blur follows each moving object's own trajectory (combined with the camera motion above), so different objects blur in different directions and amounts, again hard to model in 2-D at the boundary between a moving object and its background.

Diffraction is the well-behaved exception: the diffraction PSF (the Airy disk) is essentially shift-invariant across the frame, though some forms of vignetting (the aperture clipped by the lens barrel toward the corners, so not every pixel sees the whole aperture) modulate it off-axis.

Fixed software prefilters are convenient convolution models. Downsampling after a prefilter nevertheless discards information, and reconstruction filters do not generally undo that loss. A spatially varying resampling footprint is not one convolution over the original grid.

The pattern is clear: a real PSF can depend on (1) $1/\text{depth}$, (2) local motion, and (3) field (image) position, none of which a single shift-invariant kernel captures.

💡 Big lesson (L6.7) — most imaging blur is not a fully shift-invariant convolution

A convolution is an approximation when blur changes with depth, motion, field position, or wavelength. A small patch may support one kernel, but occlusion boundaries need particular care. Fixing geometry can preserve linearity in intensity even when shift-invariance is lost.

The difference between axial and lateral chromatic aberration changes the available correction. If wavelengths focus at different distances, a plane sharp in one channel may be blurred in another; aligning edges geometrically cannot restore the attenuated texture. If the principal difference is magnification, a per-channel warp can align much of the colored fringe. A broad channel still combines a range of wavelength-dependent magnifications, so even a successful alignment need not remove every within-channel smear. This is why the two effects should not be treated as one color-fringe problem.

Fourier⧉

MTF: a lens's frequency response⧉

optional

For an incoherent, locally shift-invariant imaging system, let $g$ be the intensity PSF. Its Fourier transform is the optical transfer function (OTF), which may be complex. The modulation transfer function is its normalized magnitude:

$$\operatorname{MTF}(u,v)=\frac{|\hat g(u,v)|}{|\hat g(0,0)|}.$$

It measures contrast transfer but omits phase shifts. An ideal finite-aperture lens is still diffraction-limited: its MTF falls with frequency and reaches a cutoff. Only an ideal impulse PSF would retain unit contrast at every frequency. Lens MTF can vary across the field and with orientation. See Chapter 22.1, Aberrations and optical challenges.

Defocus, and undoing what the lens softened⧉

Estimating the blur field⧉

optional

A depth map helps specify blur only with aperture, focus, lens response and visibility. At depth boundaries, foreground occlusion changes which rays reach the sensor, so independent local disc blurs are incomplete. Several measurements can constrain the field:

From the single image. Estimate a defocus map by measuring local sharpness, or by how much a local edge is spread, and convert it to a blur radius. It is the same estimation problem as blind deblurring restricted to a one-parameter family, which makes it far better posed, and it fails in the same places: flat regions, where there is nothing to measure the blur on, and depth discontinuities, where two blurs overlap.

From two images. Different focus or aperture settings can constrain defocus through their relative image formation. The scene must align and remain sufficiently stable; exposure changes and spectral zeros complicate a direct ratio. The result remains an estimate under a model.

From dual-pixel data. Two sub-aperture views provide a small-baseline disparity cue related to defocus (Abuolaim & Brown 2020). Calibration, texture, aperture and noise determine how informative it is. Flat regions and occlusions remain difficult, and the views are not generally identical images related only by a shift. A learned model can use both without explicitly recovering a perfect depth map.

fig-defocus-psf-zeros
Figure 16.6.1 (reproduced). Interactive. A defocus disc and its transfer function, side by side, with the aperture diameter and the depth as sliders. As the disc grows, the dips in its transfer function move inward, and the panel marks where they fall. A continuous disc of diameter $d$ has its first exact zero at $1.2197/d$ cycles per pixel; the marked points are minima of the sampled disc's radially averaged spectrum, which sit close to those zeros but are not proof of exact nulls, so the information there is buried rather than provably destroyed. Below, a test image blurred by that disc and then deconvolved with the correct kernel: the frequencies near the minima barely come back at any regularization setting, and the ringing that appears when the solver pushes on them is shown as the price. A second control puts two objects at different depths in the same frame and deconvolves with one kernel, so one depth sharpens while the other is damaged, with the band error reported for each. Interactive: set the aperture and the two depths, mark the transfer-function minima, choose the deconvolution kernel, and compare per-depth results.

The sign of a dual-pixel disparity can help distinguish which side of the focus plane a point lies on. A symmetric defocus disc alone does not provide that sign: comparable blur sizes can arise in front of and behind the chosen focus. Splitting the aperture changes the measurement so that the two subviews can resolve part of that ambiguity. Their usefulness still depends on texture and the calibrated lens response.

Measuring lens quality⧉

in the book↗

After cataloging lens defects, the next step might seem to be correction. But correction and optimization both need measurements first. The optimizer of the next chapter minimizes a number; the deconvolution of Aberrations correction inverts a measured blur; the manufacturer who sells you the lens quotes a spec; and the reviewer who pans it backs the verdict with a chart. Every one of those is a measurement. So this chapter is the assessment step that the rest of the part stands on: how do you turn "this lens is a bit soft in the corners and fringes in blue" into numbers you can optimize against, invert, advertise, or argue about? You cannot improve, target, or correct what you have not quantified: that is the whole reason this chapter comes before Lens optimization.

One measurement dominates, and we have already met the underlying machinery. Locally, a linear incoherent imaging system blurs approximately by convolution with its point-spread function; convolution is multiplication in the Fourier domain. The frequency-domain face of the lens's blur is its transfer function, and its magnitude, which tells you how much contrast survives at each spatial frequency, is the Modulation Transfer Function, the main metric of this chapter. Everything else (spot size, distortion, vignetting, color shift) is a companion measurement that the MTF either contains or sits beside.

The modulation transfer function (MTF)⧉

in the book↗

Imagine photographing not a sharp edge or a point but a smooth sinusoidal intensity pattern: bright and dark stripes whose brightness varies as a sine wave at a single spatial frequency $\nu$, measured in line-pairs per millimeter (lp/mm) at the image plane. A perfect lens would reproduce that sinusoid with its full contrast intact. A real lens, because it spreads each point into a small blob, smears adjacent bright and dark stripes into each other and the reproduced sinusoid comes out with less contrast: the peaks lower, the troughs higher. Define the modulation of a pattern as $(I_\text{max}-I_\text{min})/(I_\text{max}+I_\text{min})$, and the MTF at frequency $\nu$ is simply the ratio of output modulation to input modulation:

$$ \text{MTF}(\nu) \;=\; \frac{\text{modulation out}(\nu)}{\text{modulation in}(\nu)}. $$

Plot that ratio against $\nu$ and you get the curve familiar from lens reviews (Figure 22.3.1). It starts at $1.0$ at zero frequency (the transfer is normalized by its zero-frequency response; a uniform field itself has no sinusoidal contrast) and generally falls toward $0$ at fine frequencies, though lobes and zeros can interrupt a monotonic decline, because the finest stripes are blurred into a flat gray. Coarse detail (low $\nu$) survives well; fine detail (high $\nu$) is attenuated; somewhere the lens simply stops resolving. The MTF is the single most-used summary of what "sharpness" means, and the rest of this chapter is, in one way or another, ways to obtain it and things to plot it against.

The OTF/PSF relationship. The MTF is not separate from the blur studied in the deblurring chapters. It is that blur, viewed in the frequency domain. The lens's full frequency response is the Optical Transfer Function (OTF), and the OTF is exactly the Fourier transform of the point-spread function:

$$ \text{OTF}(\nu) = \mathcal{F}\{\text{PSF}\}, \qquad \text{MTF}(\nu) = |\text{OTF}(\nu)|. $$

The MTF is the magnitude of the OTF; the discarded phase part is the Phase Transfer Function (PTF), which retains phase shifts lost from the magnitude alone. Coma can affect both magnitude and phase; the MTF alone cannot distinguish a PSF from its mirror image. This is the same convolution-theorem duality the book keeps returning to: blurring an image is convolving by the PSF in space, which is multiplying by the OTF in frequency. The image is $\text{scene} * \text{PSF}$, and Aberrations correction's deconvolution divides by the OTF, so the MTF is literally the thing whose zeros bound what deconvolution can recover (you cannot divide back contrast the lens drove to zero). PSF and complex OTF are equivalent descriptions, while MTF discards phase; this chapter mostly works in the frequency domain because that is where "sharpness vs. detail size" reads off most cleanly.

Scalar summaries: MTF50 and limiting resolution. A whole curve is more than people want when they are ranking lenses, so the curve gets collapsed to a number or two. A common scalar is MTF50, the spatial frequency at which the MTF has fallen to $0.5$, i.e. where the lens still passes half the contrast. It is popular because it correlates well with perceived crispness: a lens with a higher MTF50 usually looks sharper. A second common scalar is the limiting resolution, the frequency at which the MTF drops to some small cutoff (say $0.1$, or the noise floor), the finest line-pairs/mm the lens still resolves at all. The two answer different questions: MTF50 is about how punchy the mid-frequencies look, limiting resolution about the absolute finest detail present.

The diffraction ceiling. For a fixed pupil amplitude and support in incoherent imaging, removing wavefront aberration gives the diffraction-limited MTF bound, because diffraction is a floor on the PSF that no amount of design removes (FUNDAMENTALS). For a circular pupil the diffraction-limited MTF falls to zero at the cutoff frequency

$$ \nu_c = \frac{1}{\lambda N}, $$

with $\lambda$ the wavelength and $N$ the image-side f-number in the paraxial air model (use the effective value at finite magnification): beyond $\nu_c$ a perfect lens passes nothing. Stopping down (raising $N$) lowers $\nu_c$, which is the frequency-domain statement of the familiar fact that small apertures soften everything by diffraction. So the diffraction curve is the ceiling in Figure 22.3.1, and a real lens's MTF lives somewhere underneath it, pushed down further by every aberration the previous chapter named.

MTFs multiply. One last fact makes the MTF the right representation for a photographic system, not just a lens. The sensor blurs (finite pixels, the anti-aliasing filter), the demosaic blurs, motion blurs, and the lens blurs, and for linear, shift-invariant stages their transfer functions multiply:

$$ \text{MTF}_\text{system}(\nu) = \text{MTF}_\text{lens}(\nu)\cdot\text{MTF}_\text{sensor}(\nu)\cdot\text{MTF}_\text{AA}(\nu)\cdots $$

This is why a superb lens on a coarse sensor still looks soft (the sensor's MTF caps the product), and why "system MTF" (lens and sensor and pipeline together) is what photography actually cares about. Adaptive denoising, nonlinear demosaicking, sharpening, and sampling can violate this simple factorization. A measured system response then depends on the target and settings, rather than being one universal product.

fig-mtf-curves
Figure 22.3.1 (reproduced). The MTF: how much contrast survives, frequency by frequency. Modulation transfer (vertical, contrast retained, $1$ down to $0$) plotted against spatial frequency in line-pairs/mm (horizontal), for three hypothetical lenses (a premium prime, a kit zoom, and a soft/cheap lens) against the diffraction-limited envelope for the aperture (the ceiling no lens can beat). Every curve starts at $1.0$ and falls toward $0$; the sharper lens holds its contrast to higher frequencies. MTF50, the frequency where each curve crosses $0.5$, is marked as the single-number sharpness score, and the diffraction cutoff $\nu_c=1/(\lambda N)$ sits at the right as the hard limit.

Measuring MTF in practice⧉

optional

So far the MTF is a definition. How do you actually obtain it from a lens on a bench? There are two families of method, and the second one is the workhorse of modern testing.

Direct: sinusoidal and Siemens-star targets. The literal approach is to photograph the very thing the definition describes (a chart of sinusoidal patterns at a ladder of known frequencies) and read the output modulation off each, frequency by frequency. It is conceptually pure but fussy: you need an accurate sinusoidal target, careful exposure, and one patch per frequency. A neat refinement is the Siemens star, a radial pattern, sinusoidally modulated for direct MTF measurement or formed from binary wedges for a simpler resolution check, whose spatial frequency rises smoothly toward the center; a single star sweeps a whole range of frequencies in one shot, and the radius at which its spokes blur into gray reads off the limiting resolution. These methods give trustworthy MTF numbers and are still used for careful lab work.

The slanted-edge (SFR) method: ISO 12233. The method that took over, because it needs only one frame of one edge, is the slanted-edge or spatial-frequency-response (SFR) technique standardized as ISO 12233. Photograph a sharp black-to-white edge tilted a few degrees off vertical. The slant provides subpixel sampling: because the edge is slanted, each successive row of pixels crosses it at a slightly different sub-pixel position, so the rows together sample the edge profile at a much finer spacing than the pixel pitch. Pooling all the rows (projecting each pixel onto the axis perpendicular to the edge and binning) yields a super-resolved profile of the edge: the edge-spread function (ESF), what the lens-plus-sensor does to an ideal step. The slant yields finer sampling than the pixel pitch alone.

From the ESF the rest is mechanical (Figure 22.3.2). Differentiate the ESF and you get the line-spread function (LSF), the response to a thin line rather than an edge, which is the two-dimensional PSF integrated along the edge direction. Fourier-transform the LSF and take the magnitude, normalized so the zero-frequency value is $1$, and you have the MTF (in this context usually called the SFR). The compact chain below omits the DC normalization; implementations also linearize pixel values, window the LSF, and compensate the numerical derivative. Avoid clipped edges and document processing. The chain is the whole method in one line:

$$ \text{edge} \;\to\; \text{ESF} \;\to\; \text{LSF} = \frac{\mathrm{d}}{\mathrm{d}x}\text{ESF} \;\to\; \text{MTF} = \bigl|\mathcal{F}\{\text{LSF}\}\bigr|. $$

This method is cheap, repeatable, and automatable. Open implementations (Burns's sfrmat, the open-source MTF Mapper) read the chart and spit out curves, which is one reason camera reviews and QA lines rely on it. Crucially, it measures the whole system: lens, sensor, anti-aliasing filter, demosaic, and any ISP sharpening, all folded into one curve (the product of MTFs from the previous section). For photography that is useful: it is the sharpness you will actually get, though it means you must hold the sensor and processing fixed if you want to compare lenses.

fig-slanted-edge-sfr
Figure 22.3.2 (reproduced). The slanted-edge (SFR) method: one edge → ESF → LSF → MTF. Four panels left to right. (1) A black/white edge tilted a few degrees, so successive rows sample it at different sub-pixel phases. (2) Pooling all rows gives a super-resolved edge-spread function (intensity vs. distance to the edge). (3) Its derivative is the line-spread function, the 1-D point-spread. (4) The magnitude of the LSF's Fourier transform, normalized to $1$ at zero frequency, is the MTF (here, the measured curve recovers the known system blur, shown dashed). This is the ISO 12233 pipeline, computed on a synthetic edge.

Where, and in which direction. A single curve hides the fact that the MTF is not one number even for one lens at one aperture: it varies across the field and with the orientation of the detail, so a real measurement is a small matrix of curves. Across the field, a lens is nearly always sharpest on the optical axis and softer toward the corners (aberrations grow with field angle), so the bench measures the MTF at several image heights (center, mid-frame, and corner) not just on-axis. Orientation matters because at any off-axis point two special directions behave differently: sagittal structures, oriented radially (spoke-like, pointing at the frame center), and meridional (also called tangential) structures, oriented across the radius (concentric, rim-like). Off-axis astigmatism (Chapter 22.1, Aberrations and optical challenges) brings these two orientations to focus at slightly different distances, so the lens resolves one better than the other and their MTF curves separate; on-axis, by symmetry, the two coincide. This is exactly what a manufacturer's MTF chart shows (Figure 22.3.3): contrast plotted against image height, with often a solid curve for sagittal and a dashed curve for meridional (check the legend and whether the curves are measured or calculated), usually at two frequencies: a low one (around 10 lp/mm) that reads as contrast and "character," and a higher one (around 30 lp/mm) that reads as fine-detail sharpness. Do not confuse the orientation of test lines with the perpendicular direction in which their intensity varies. Manufacturers and measurement programs can use different sagittal/tangential labeling conventions. Once you know the conventions, the chart is easy to read: curves that stay high and flat mean even sharpness to the edge; a large sagittal–meridional gap indicates directional differences that can arise from astigmatism, coma, and other effects; both falling together means plain corner softness; and a low-frequency curve that sags signals veiling flare or low micro-contrast rather than lost resolution.

fig-mtf-field-directions
Figure 22.3.3 (reproduced). Where and in which direction the MTF is measured. Left, the two things that make MTF a matrix rather than a number: the lens is tested at several image heights (center, mid-frame, corner), and at each off-axis point the detail's orientation matters: sagittal (radial, spoke-like) versus meridional / tangential (concentric, rim-like). Right, the manufacturer-style chart that results: contrast against image height, solid for sagittal and dashed for meridional, at a low frequency (~10 lp/mm, contrast) and a high one (~30 lp/mm, fine detail). Both curves fall toward the corner; a gap between the solid and dashed pair is the signature of off-axis astigmatism.

Spot diagrams and the PSF⧉

optional

The MTF lives in the frequency domain; its space-domain twin is the point-spread function and, for a designer working from a ray model, the spot diagram. As Lens optimization develops in detail, you can estimate the PSF geometrically by tracing a fan of rays from one field point through the lens and scattering their landing points on the image plane (Figure 22.4.1). A tight cluster means the lens brings that point nearly to a point (sharp; a smeared blob means it does not) and, as the previous chapter showed, the shape of the blob diagnoses which aberration dominates (a round haze is spherical, a one-sided comet is coma, an ellipse is astigmatism).

For measurement purposes the spot diagram hands us a scalar (the RMS spot radius, the root-mean-square spread of the landing points) which is the classical sharpness metric the merit function of the next chapter shrinks. And experimentally, rather than tracing rays, you can simply image a point source (a pinhole or a distant star) through the real lens and photograph its PSF directly. That measured PSF is precisely what Aberrations correction feeds to deconvolution. So the same lens quality appears in three forms: as a measured PSF (image of a point), as a ray-traced spot diagram (the design's prediction), and as an MTF (the magnitude of the Fourier transform of a normalized PSF). A ray spot diagram omits diffraction and needs appropriate ray weights to approximate an intensity PSF. It is useful when geometric blur dominates; it is not interchangeable with a measured diffraction-inclusive PSF near the diffraction limit.

MTF through focus and depth of focus⧉

optional

Everything above measured the MTF at the best focus. But focus is itself an adjustment, and asking how the MTF behaves as you change focus answers a different and very practical question. Fix a single spatial frequency, then slide the sensor (or refocus the lens) and re-measure the MTF at each position. The contrast rises to a peak at best focus and falls away on either side: the through-focus MTF (Figure 22.3.4). The position of the peak is best focus; the width of the peak is the depth of focus: the range of sensor positions over which that frequency stays above a usable contrast. (Depth of focus is the image-side cousin of the FUNDAMENTALS depth of field on the subject side; they are linked by magnification.)

Two features make this measurement diagnostic. First, higher spatial frequencies give narrower through-focus peaks: fine detail demands more precise focus than coarse detail, so the depth of focus shrinks with the detail you ask for: a low-frequency target tolerates sloppy focus, a high-frequency one does not. Second, if the through-focus peaks for different frequencies (or for different field points, or different colors) sit at different focus positions, that offset is a signature of residual aberration: spherical aberration shifts best focus with frequency, field curvature shifts it with field, axial chromatic aberration shifts it with color (the next section). A perfectly corrected lens would have all its peaks aligned; the offsets reveal the residual aberrations.

fig-mtf-through-focus
Figure 22.3.4 (reproduced). Through-focus MTF: the peak is best focus, its width is depth of focus. MTF at a fixed spatial frequency plotted against focus position (sensor defocus, µm), for a coarse and a fine frequency. Each curve peaks at best focus and falls on either side; the fine-frequency peak is narrower (fine detail demands sharper focus), and the span where it stays above a usable-contrast threshold is the depth of focus, marked. A small offset between the two peaks is the through-focus signature of residual spherical aberration.

Field-dependent MTF: sagittal vs tangential⧉

optional

A lens is sharp in the center and softer toward the corner, so a single MTF number for "the lens" hides where it is good and where it gives up. The standard published chart therefore plots the MTF against image height (distance from the optical center, in millimeters, from $0$ at the center out to the corner) at a coarse frequency (say $10$ lp/mm, which tracks contrast and "punch") and a fine frequency (say $30$ lp/mm, which tracks fine resolution). And each of those is split again into two curves, because off-axis a lens treats two orientations of detail differently: sagittal detail (lines running radially, toward the center) and tangential detail (lines running across the radius, azimuthally) focus differently. So the manufacturer chart is four curves (sagittal and tangential at each of two frequencies) plotted center to corner (Figure 22.3.5).

Reading the chart is straightforward once you know what the curves mean. Both curves falling toward the corner is the ordinary off-axis softening, as coma, field curvature, and lateral color pile up where the previous chapter said they would. The more telling feature is the gap between the sagittal and tangential curves: that gap can indicate astigmatism or other directional aberrations. Through-focus measurements can reveal whether radial and tangential detail reach best focus on different planes; when they do, one sensor plane cannot render both at their sharpest. A lens whose four curves stay high and together across the whole frame is "even"; one whose corners collapse, or whose sagittal and tangential curves split wide apart off-axis, is dumping quality into the edges, exactly the compromise Lens optimization will show being negotiated, and exactly the corner softness Aberrations correction may be asked to claw back.

fig-mtf-field
Figure 22.3.5 (reproduced). MTF across the field: sagittal vs tangential, center to corner. MTF plotted against image height (mm from center) at a coarse and a fine spatial frequency, each as a sagittal (solid) and tangential (dashed) pair, the standard manufacturer chart. Contrast is high in the center and falls toward the corner; the gap that opens between the sagittal and tangential curves is astigmatism (radial and tangential detail focusing at different planes). An even lens keeps its curves high and together; a compromised one lets the corner collapse or split.

Color, geometry, and illumination measurements⧉

optional

The MTF and its through-focus and field variants quantify blur. But the previous chapter's catalog had defects that are not blur at all (color misregistration, displaced geometry, darkened corners) and each has its own measurement, which (not coincidentally) is exactly the data the lens-profile correction of Aberrations correction needs.

Lateral (transverse) chromatic aberration is a difference in magnification between color channels, so it is measured as a per-channel radial scale: image a high-contrast target, find where the red, green, and blue edges land as a function of field, and fit the tiny scale factor that separates them. It comes out as one magnification offset per channel, which is precisely the per-channel radial rescale the ISP plays back to collapse the colored fringe.

Longitudinal (axial) chromatic aberration is instead a difference in focus depth between colors, so it is measured through focus: find the best-focus sensor position for red, green, and blue separately, and the spread between them is the axial color. It is the through-focus measurement of the previous section, repeated per wavelength, and it is what achromat and apochromat design (and, partially, deconvolution) aim to flatten.

Geometric distortion is measured by imaging a ruled grid and quantifying how far the imaged lines bow from straight, then fitting the Brown–Conrady coefficients $k_1, k_2, \dots$ (or the division-model $\lambda$) defined in the challenges chapter; the result is reported as a percent distortion versus field. Those fitted numbers are exactly the coefficients the radial-warp correction inverts.

Vignetting / relative illumination is measured by photographing a uniform field and recording the radial brightness falloff: corner brightness relative to center, in stops or percent. A single uniform-field image measures their combined effect, including sensor angular response; it does not separate the mechanisms by itself. Aperture-dependent measurements and a model can help isolate optical clipping. The calibrated combined response supplies the gain map used to even the frame.

Field curvature is measured by mapping best-focus depth versus field: the surface on which the image is actually sharp is not the flat sensor but a curved (Petzval) surface, and tracing that surface predicts how soft the corners go when the center is nailed. It is the spatial bookkeeping behind why "flat-field" designs are prized.

Each of these is a small, targeted measurement, and each one's output is the input to a correction in the next chapters: the clean illustration of why measurement has to come first.

Scalar quality summaries⧉

optional

Finally, the field wants a single number to rank lenses and to hand an optimizer, so the rich curves above get collapsed, at a cost. The common scalars are the ones we have already met: MTF50 and limiting resolution (lp/mm) from the MTF curve, RMS spot radius from the spot diagram, and the wavefront-error metrics: RMS wavefront error and its companions the Strehl ratio (peak intensity of the real PSF relative to the diffraction-limited one) and the Maréchal criterion (a lens is "diffraction-limited" if its RMS wavefront error is below about $\lambda/14$). Some summaries go further and weight the MTF by the human contrast-sensitivity function to predict perceived sharpness: the family of "blur index" or acutance scores (SQF and its relatives).

The plain caveat is that every one of these is a lossy summary of a much larger object: a fuller description includes MTF and phase over frequency, field, focus, and color, together with transmission, distortion, flare, and other properties, effectively a hypercube, and any single number throws most of it away. A scalar is genuinely useful for ranking lenses and, especially, as an optimization target the next chapter can drive down; but it hides where in the frame, at what detail size, and in what color the lens is good or bad. That is the right note to end on, because it is the seam to the rest of the part: this chapter produces the scorecard, Lens optimization compresses it into a merit function and minimizes it, and Aberrations correction takes the measured PSF, distortion, vignetting, and color maps and inverts them. Measurement first; then you optimize, and then you correct what optimization left behind.

Focus⧉

Focus stacking, macro, and focusing rails⧉

optional

Focusing gets hardest exactly where you need it most precise: up close. At macro magnifications the depth of field collapses to millimeters or less (FUNDAMENTALS), so a single frame cannot hold even a small three-dimensional subject sharp from front to back. There are two mechanical responses, and they differ in a way that matters for perspective.

The first is focus stacking: capture a stack of frames at stepped focus settings, then combine them by keeping, at each pixel, the sharpest slice. This is the depth-from-focus machinery of the next chapter used to build an all-in-focus image rather than a depth map, and its full treatment lives in Depth of field; many cameras now automate the stepping as in-camera focus bracketing. The catch is the focus breathing noted above: because internal focusing changes magnification slightly from frame to frame, the slices are at subtly different scales and must be registered before they can be merged.

The second response avoids refocusing altogether. Instead of changing the lens's focus setting between frames, mount the whole camera on a focusing rail and slide it forward by a fixed step for each shot. The lens stays at one focus setting, so its magnification and aberration correction do not change; what changes is the camera-to-subject distance, moved mechanically. This is the standard rig for high-magnification macro and for microscope-objective work, and it is easily motorized (rigs like StackShot step the rail and trigger the shutter automatically). But moving the whole camera moves the entrance pupil, which means it also changes the perspective slightly from frame to frame, the near parts of the subject shifting against the far parts, so the slices have to be aligned for viewpoint as well as scale before stacking. It is a real tradeoff against in-place refocusing: the rail keeps the optics constant but changes where you are looking from, while refocusing changes the optics and may also shift the entrance pupil. Landscape photographers meet a gentler version of the same idea, blending two or three frames focused near and far to carry a foreground and a horizon both sharp.

Bokeh, focus stacking, and depth-of-field control⧉

The geometry of focus⧉

optional

Everything quantitative about depth of field was derived in FUNDAMENTALS, and this section only reminds you of the results so the rest of the chapter has them in hand. Focus a lens on one plane; a point exactly on that plane sends a cone of rays that reconverges to a sharp point on the sensor. A point nearer or farther focuses behind or in front of the sensor, so by the time its cone reaches the sensor it has opened (or reopened) into a small disk: the circle of confusion (CoC), of diameter that grows with the aperture and with the point's distance from the focus plane. A point counts as "sharp" while its circle of confusion stays under a tolerance diameter $c$ set by sensor resolution and viewing size (Figure 23.1.1, and the full geometry in FUNDAMENTALS).

fig-dof-coc
Figure 23.1.1 (reproduced). The circle of confusion (recap). Side view of a lens focused on one plane. A point on the focus plane reconverges to a sharp point on the sensor; a nearer point focuses behind the sensor and a farther point in front of it, so each lands as a blur disk, the circle of confusion of diameter $c$ at the depth-of-field limits. Mark the near and far limits where the disk reaches the tolerance $c$, and the band between them as the depth of field. A small inset pointer references FUNDAMENTALS Chapter 2.2, Pinhole image formation and linear perspective for the full similar-triangles derivation rather than repeating it.

The band of acceptably-sharp distances is bounded by a near limit and a far limit, fixed (via similar triangles and the conjugate relation $1/f = 1/u + 1/v$) by where the circle of confusion reaches $c$. The nearest focus setting whose acceptable far limit reaches infinity is the hyperfocal distance

$$H = \frac{f^2}{Nc}+f \;\approx\; \frac{f^2}{Nc},$$

where $N = f/D$ is the f-number. In the thin-lens model, focus at $H$ and the near limit is $H/2$, with the far limit at infinity. The three knobs all push the same way, and they are the right intuition to keep in mind: depth of field grows with a smaller aperture (larger $N$), a shorter focal length $f$, and a greater focus distance. Stopping down is the photographer's main lever, but it costs light and, pushed too far, hands the image to diffraction (previous chapters), a wall the focus-stacking section will go around. Two further FUNDAMENTALS results matter below. First, depth of field is really about magnification, not focal length: for fixed magnification, f-number, and blur tolerance, the near-subject depth-of-field approximation is largely independent of focal length (the framing-invariance result), so "telephotos have shallow depth of field" is, as stated, a myth. Second, sensor size scales depth of field: shrink the sensor while keeping viewpoint, framing, f-number, and final viewing size fixed, and depth of field increases approximately inversely with the sensor's linear scale, which is exactly why phones have enormous depth of field and must fake the shallow look.

Finally, the load-bearing caveat that this whole part keeps returning to: defocus is not a 2-D convolution of the image. The blur radius at each pixel depends on that point's scene depth, not its image position, so the blur is spatially varying in a way tied to 3D structure; and at depth discontinuities occlusion matters: the foreground's blur should bleed over the background, and some background hidden from the center viewpoint may be visible through other pupil positions. A single central image does not contain all that background. A flat disk blur can do neither. This is precisely why naive portrait-mode fakes break at hair and edges, and why the depth-aware and light-field methods (forward-ref to the Advanced part) exist. Keep this in mind through the bokeh section: even within the in-focus-vs-out-of-focus story, the out-of-focus part has real optical structure that a convolution would erase.

Extending DoF: focus stacking⧉

optional

Sometimes there is simply no aperture that gives enough depth of field. Photograph an insect at life size and the sharp band is a fraction of a millimeter deep: the antennae are sharp and the eyes are already gone. Stopping down should help, and it does, until diffraction (FUNDAMENTALS) softens the whole frame and you lose at the focus plane what you gained in depth; for macro work that diffraction wall arrives long before you have the depth you want. The same problem appears at the other end of scale (a landscape with flowers a foot from the lens and a peak at infinity) and in product and studio work. The answer is to give up on getting the depth of field from a single exposure and instead build it from many: focus stacking.

The recipe is simple to state. Capture a stack of frames at stepped focus distances, each one sharp in a thin slice of the scene, with the slices overlapping so that together they cover the whole depth range. Then composite the result by keeping, for each pixel (or small region), the sharpest sample across the stack, and assembling those sharpest pieces into a single all-in-focus image (Figure 23.1.4). "Sharpest" is measured with the very same high-frequency-energy / local-contrast metric that drives contrast-detection autofocus and depth-from-focus in the previous chapter. Focus stacking is depth-from-focus that keeps the image instead of the depth. Done well, it produces a picture with depth of field that no real aperture on that lens could deliver, and without the diffraction penalty, because each slice can be shot near a useful sharpness optimum. Diffraction is still present at that aperture; stacking avoids the additional diffraction of stopping down much further.

fig-focus-stacking
Figure 23.1.4 (reproduced). Focus stacking: a stepped-focus stack composited to all-in-focus. Left: a stack of frames of a deep subject, each focused at a different distance so a different thin slice is sharp while the rest blurs. Center: a per-pixel sharpness map selecting, for each region, the frame in which it is sharpest (the same contrast metric used by contrast-detection autofocus). Right: the composite, sharp from front to back. Each slice was shot at the lens's optimal aperture, so the result beats the diffraction limit that stopping down a single frame would hit. The full algorithm (the sharpness measure, the weighted merge, and the seamless graph-cut/Poisson version) is developed in the Focal stacks and depth of field extension chapter of Multiple exposure imaging.

The catch is registration. As you rack focus, the lens does not only change which plane is sharp; it usually changes the magnification of the whole frame slightly: the image breathes in or out. This focus breathing means that a feature sits at a slightly different pixel between two slices, so the frames must be aligned (scaled and shifted to a common frame) before the sharpest-pixel selection, or the composite will show double edges and halos. Focus stacking is therefore a multi-image fusion problem of exactly the kind the book treats elsewhere (register, then select/blend per pixel) and the same alignment-and-fusion machinery (cross-ref the fusion/stacking discussion in the multi-exposure part) applies. The comparison with stopping down is the main point here: stopping down buys depth of field at the cost of light and, eventually, diffraction softening the whole image; focus stacking buys it at the cost of several exposures, registration, fusion, and potential motion or occlusion artifacts, and beats the diffraction wall by never asking any single frame to do more than it can.

Controlling and faking DoF⧉

optional

Depth of field is a creative control, so the last question is how to get the depth of field you want in either direction. Making it shallow on purpose uses the FUNDAMENTALS levers, with several interacting controls. The instinct is to "use a longer lens," but the framing-invariance result says that, for a fixed subject size and a fixed f-number, focal length barely changes the depth-of-field band. What actually thins it is magnification, getting the subject larger on the sensor, together with a wide aperture. So the practical recipe for a strongly blurred background is: open up to your widest usable f-number, get the subject big in the frame (step closer, or use a longer lens and fill the frame the same way), and put a lot of distance between the subject and the background so the background's defocus disks grow large. The long lens does help the background look more blurred, but, as FUNDAMENTALS noted, that is because it magnifies the already-out-of-focus disks, not because it shrank the depth-of-field band around the subject.

The opposite problem is common on phones, which cannot physically produce much shallow depth of field, and it is solved in software: fake or computational depth of field, the portrait-mode effect offered by many phones. The reason it is needed is the sensor-size scaling above: a phone's tiny sensor gives it huge depth of field, so to imitate a large-sensor portrait the phone must synthesize the background blur. The pipeline is: estimate a depth map for the scene (from the dual-pixel disparity of the previous chapter, from a second camera's stereo, or from a learned monocular-depth network) and then apply a depth- and occlusion-aware blur, growing the blur radius with each pixel's distance from the chosen focus plane and rendering a chosen disk shape (so the synthetic highlights can even be made to look like a particular lens's bokeh). And here the load-bearing caveat from the recap comes back to bite: because defocus is not a 2-D convolution, a naive "blur the background uniformly" cannot work. The blur has to follow scene depth, and at object edges the foreground's blur must bleed over the background while the hidden background peeks through. This is exactly why portrait-mode failures cluster at hair, fine edges, and transparency, where the depth map is uncertain and the occlusion bookkeeping is hardest. We are only setting up why the problem is hard and what a depth map buys; the full, occlusion-aware treatment (and the light-field cameras that sidestep it by capturing the rays directly and refocusing after the fact) is forward-referenced to the Advanced computational-camera part.

Fake (synthetic) depth of field⧉

optional

A large-sensor camera with a fast lens isolates its subject by physics: the background falls outside a shallow depth of field and dissolves into the soft, structured blur the last chapter dissected. A phone usually produces less optical background blur for a comparable portrait, though close focus or a telephoto module can still give visible defocus. Its sensor is fingernail-sized and its lens is correspondingly short, and (by the sensor-size scaling FUNDAMENTALS derived and Chapter 23.1, Bokeh, focus stacking, and depth-of-field control restated) that combination gives it an enormous depth of field in which almost everything is sharp at once. For snapshots this is a gift; for portraits it reads as flat, busy, un-cinematic. So the phone does in software what the glass cannot do in hardware: it estimates the scene's depth (or at least which pixels are the subject), then synthesizes the background blur, growing the blur with defocus and shaping it like a real aperture. This is fake, or synthetic, depth of field, the effect usually marketed as portrait mode. It is the computational counterpart to the optical depth of field of the previous chapter, and the whole of it is a pipeline whose stages we take in turn: why phones must fake it, where the depth comes from, how depth becomes a blur radius, why a Gaussian betrays the fake, how occlusion is handled, and where it all breaks.

Why phones must fake it⧉

optional

The root cause is the capture geometry. At matched viewpoint, framing, f-number, and final viewing size, a smaller sensor uses a shorter focal length and gives greater depth of field. These are linked quantities, not two independent causes. A wider entrance pupil can reduce depth of field, but the aperture needed to match a large-format fast portrait lens may be impractical in a phone. Phones can produce optical defocus, especially close up; portrait mode extends its strength and flexibility beyond what a particular module captures.

What photographers want from a portrait, though, is exactly the opposite: the subject isolated, lifted off a soft background that does not compete for attention. Since the optics refuse to deliver it, the phone computes it. "Portrait mode" estimates where each pixel sits in depth (or, more cheaply, simply which pixels belong to the subject and which to the background) and then blurs everything that is not the subject by an amount that grows with its distance from a chosen virtual focal plane, painting in a believable aperture-shaped blur as it goes (Figure 23.2.1). The output is a picture meant to resemble one from a large sensor and a fast lens, assembled from one that did neither. This is the computational sibling of the optical Chapter 23.1, Bokeh, focus stacking, and depth-of-field control chapter. It aims for the same visual result by different means.

The idea predates portrait mode by a decade. An early take was defocus magnification Bae & Durand 2007 (Defocus Magnification): from a single small-sensor photo, estimate the slight defocus blur already present at each edge, use it as a cheap proxy for depth, and then magnify it to fake a shallower depth of field. The technique provides an instructive alternative to the dual-pixel, stereo, and learned depth cues used in later systems but it is the conceptual ancestor of everything in this chapter: measure what little defocus cue a small camera does have, and amplify it into the look of a big one.

fig-portrait-mode-pipeline
Figure 23.2.1 (reproduced). The portrait-mode pipeline on one photograph. Four panels left to right: (1) the input, a deep-depth-of-field phone capture in which the subject and the cluttered background are both sharp; (2) the estimated per-pixel depth (or subject/background) map, shown as a grayscale layer, near = bright, far = dark; (3) the depth-aware blur, each background pixel splatting an aperture-shaped disk whose radius grows with its distance from the virtual focal plane while the subject stays untouched; (4) the composited result, the crisp subject sitting on a smoothly blurred background with bloomed highlight disks. A caption note marks the subject silhouette as the region where matting errors are most visible.

Where the depth (or subject) comes from⧉

optional

A synthetic blur is only as faithful as the depth that drives it, and there are four places a phone can get that depth, in rough order of hardware cost. The first is dual-pixel disparity. As Chapter 22.9, Autofocus explained, a dual-pixel sensor splits every photosite into two half-photodiodes under one microlens, so the left and right halves see the left and right halves of the lens's pupil, a stereo pair with an effective baseline determined by the separated pupil regions inside a single lens. Correlating the left-half image against the right-half image gives a dense, if shallow, per-pixel disparity, and the signed disparity constrains defocus relative to the current focus setting. Converting it to depth requires calibration and becomes uncertain when disparity is small. This is precisely the signal Wadhwa et al. exploited in their 2018 Synthetic Depth-of-Field with a Single-Camera Mobile Phone Wadhwa et al. 2018, the basis of Google's single-camera Portrait mode, which extracts a usable depth map from one lens by reading the dual-pixel split.

fig-synthetic-dof-1
Figure 23.2.2 (reproduced). The real single-camera Portrait Mode pipeline. (a) The input, an all-in-focus phone photo with the subject's face detected; (b) a person-segmentation mask isolating the subject; (c) that mask combined with a noisy per-pixel disparity/depth map read from the sensor's dual-pixel (DP) auto-focus hardware; (d) the output, a synthetic shallow-depth-of-field portrait produced by a depth-dependent blur, the system Google ships as "Portrait Mode." Wadhwa et al. 2018

The second source is multi-camera stereo: a phone with two rear lenses has a real (if small) baseline between them, and the classic two-view matching of Chapter 12.3, Sparse matching yields a depth map, subject to the usual headaches of textureless regions and half-occluded pixels that any stereo system fights. Because the baseline is short and the match must run on a power budget, fast approximate solvers matter; Barron et al.'s 2015 Fast Bilateral-Space Stereo Barron et al. 2015 is the canonical move here, solving the stereo (and the subsequent edge-aware depth smoothing) in a bilateral space so that the depth snaps to image edges cheaply enough to run on a phone. The third source needs no special hardware at all: monocular depth networks that predict depth from a single image, the subject of Chapter 36.3, Monocular depth estimation (one image → depth). They are metrically loose (they recover relative depth far better than absolute distance) but for a blur whose only job is to look plausible, relative depth ordering is most of what matters.

The fourth source is a practical shortcut, often combined with the other cues: segmentation and matting. Often a full depth map is overkill, because the photographer only wants "the person sharp, everything else soft." A clean subject mask (a person-segmentation network, refined into a soft alpha matte as in Compositing, segmentation and matting) suffices to blur everything that is not the subject, with no per-pixel depth at all. The cost is that the background is then blurred uniformly rather than progressively by distance, so a far wall and a near shoulder behind the subject get the same blur; the gain is robustness and speed. In practice a production portrait mode blends these sources (dual-pixel or stereo depth where it is reliable, a learned matte to nail the subject's silhouette, a monocular net to fill the gaps) because each works best in cases where the others are less reliable.

fig-synthetic-dof-2
Figure 23.2.3 (reproduced). Graceful fallback between the two depth sources. (a) On a front-facing camera lacking dual pixels, the shot is almost always a person against a distant background, so a segmentation mask alone suffices: blur everything outside the subject. (b) On a close-up of objects with no people to segment, the dual-pixel disparity alone carries a usable depth map and drives the blur directly. The production system leans on whichever input is available, degrading gracefully rather than failing when one is missing. Wadhwa et al. 2018

From depth to blur: the thin-lens circle⧉

optional

Given a depth (or subject) map, an ideal thin-lens model supplies a useful mapping to blur size. Choose a virtual focal plane at depth $z_f$, usually the subject's distance, and give each pixel a blur kernel whose radius grows with how far that pixel's depth $z$ departs from the focal plane. This is the same circle-of-confusion law that governs a real lens, imported wholesale from Chapter 23.1, Bokeh, focus stacking, and depth-of-field control and FUNDAMENTALS:

$$ c(z) \;\propto\; \left| \frac{1}{z_f} - \frac{1}{z} \right|. $$

The proportionality constant rolls up the chosen virtual aperture and focal length: it is the knob the "blur strength" slider turns. The structure of the formula is what matters: a pixel at the focal plane ($z = z_f$) gets zero blur and stays razor sharp; a pixel far behind the subject gets a large kernel; and because of the reciprocals, the blur grows asymmetrically: an equally distant displacement in front of focus produces more blur than one behind, since inverse depth changes faster nearby. Background blur approaches a finite limit as $z$ tends to infinity. A phone can evaluate this per pixel trivially fast.

That is the whole of the easy part, and the equation itself is straightforward; the difficulty lies in the surrounding stages. The thin-lens law supplies a geometric blur size under its assumptions; it tells you nothing about the shape of the kernel (the next section), nothing about what happens at the silhouette where a sharp subject meets a blurred background (the section after), and it presupposes a depth map whose accuracy at edges is precisely where the depth sources above are least trustworthy. The circle-of-confusion mapping is the least contentious stage of the pipeline, but an incorrect depth scale or arbitrary radius clamp can make even this mapping visibly wrong.

Realistic bokeh: why a Gaussian looks fake⧉

optional

A Gaussian often fails to reproduce the appearance of an aperture-shaped defocus highlight. Its smooth bell has neither the approximately uniform interior of an ideal circular pupil image nor a polygonal iris boundary. Real bokeh can also be soft-edged because of apodization or aberration, so a hard disk is not universally correct. Both a normalized Gaussian and a normalized disk spread a point's energy and reduce its peak. The conspicuously bright disks in photographs often come from sources whose radiance greatly exceeded the saturation level of the sharp input image. Clipping has discarded that excess; blurring the clipped image cannot recover it (Figure 23.2.4).

fig-gaussian-vs-bokeh
Figure 23.2.4 (reproduced). Why a Gaussian looks fake. The same defocused background (a scatter of bright point highlights and some texture) rendered two ways. Left: a flat Gaussian blur, uniform mush, no disk shape, highlights smeared into dim soft blobs that have lost their brightness. Right: a true aperture-disk bokeh, each highlight a hard-edged round disk, the clipped bright points bloomed into bright disks that keep their intensity to the rim, polygonal disks where a bladed aperture is simulated. An inset shows the two kernels side by side: a soft bell vs. a flat-topped disk.

Scatter and gather are two ways to evaluate a blur operator. A scatter renderer visits each source pixel and distributes its contribution through a kernel determined by that source's depth. A gather renderer visits each output pixel and sums the source contributions that reach it. If both implement the same weights and visibility, they produce the same image; energy conservation is not exclusive to scatter. For an unoccluded source splat, normalize its kernel to total weight one. Neither that normalization nor switching loop order restores radiance lost to clipping.

The implementation tradeoff is real. Scatter creates overlapping writes and often needs atomics or tiled accumulation on a GPU; gather has more regular output writes but must search the correct source footprints rather than apply only the destination pixel's radius. Depth boundaries require visibility in either implementation. Process radiance in linear light, retain HDR values when available, and treat highlight boosting from an LDR input as an artistic estimate. Learned bokeh renderers, including work in the AIM Bokeh Effect Rendering challenges, can learn appearance and edge handling jointly, but their output still depends on training data and the information in the capture.

Occlusion-aware compositing and matting⧉

optional

Here the main caveat from Chapter 23.1, Bokeh, focus stacking, and depth-of-field control matters directly: defocus is not a 2-D convolution. A real lens does not blur the flat image; it blurs the scene, in depth, and at every depth discontinuity the geometry is subtle. A sharp foreground subject must occlude the background behind it: the background's blur grows right up to the subject's silhouette and stops, while the crisp subject sits cleanly on top. Run a naive whole-image blur instead, and the subject's own sharp edge gets dragged outward into the blur, painting a tell-tale bright or dark halo around the person, the single most recognizable artifact of a bad portrait fake (Figure 23.2.5).

fig-occlusion-aware-blur
Figure 23.2.5 (reproduced). Occlusion-aware blur vs. naive convolution. Left: a sharp foreground subject over a background, blurred by a naive 2-D convolution of the whole image, so the subject's hard edge bleeds into the blur, leaving a bright/dark halo ringing the silhouette. Right: the same scene rendered depth- and occlusion-aware, where the background blurs only up to the subject's silhouette, the crisp subject occludes it, and the edge is clean. A zoom inset on the shoulder shows the halo in one and its absence in the other.

The fix is to render in depth order, as layers, rather than convolving the image as a single sheet. Estimate foreground color, alpha coverage, and a completed background; a matte alone does not supply those hidden colors. Blur the completed background and composite the sharp premultiplied foreground over it. For a defocused foreground, blur its premultiplied color and alpha consistently before compositing, so the subject's edge is never smeared into the blur. This exposes a measurement limitation of synthesis from one central view: disocclusion. When the foreground edge softens, a real lens reveals a sliver of background that was hidden directly behind the sharp subject, but the phone never captured that sliver, because it has no light field, only a single all-in-focus image. That background has no real data; it must be inpainted or guessed. This is the irreducible gap between fake and optical depth of field: the phone is filling in geometry it never saw.

And the matte itself is the battleground, because the silhouette is rarely a clean line. Hair, fur, foliage, and glass defeat a hard binary mask (a strand of wind-blown hair is half subject, half background within a single pixel) so portrait modes lean on alpha matting: a soft, fractional foreground coverage per pixel that lets the blur blend partially through wisps of hair. Abuolaim & Brown's 2020 work on defocus from dual-pixel data Abuolaim & Brown 2020 is instructive here, using dual-pixel measurements for defocus deblurring. It illustrates the value of that extra measurement, rather than establishing that depth estimation alone solves matting. Even so, alpha matting is hard, and it leaves residue, which is the cue for the examples below.

fig-defocus-dualpixel-1
Figure 23.2.6 (reproduced). The dual-pixel defocus cue. A narrow-aperture shot (A) is nearly all-in-focus; a wide-aperture shot (B) is shallow but defocused, and B's sensor also delivers left/right sub-aperture views, whose disparity is a per-pixel defocus/depth signal that drives a deblurred version of B Abuolaim & Brown 2020.
fig-defocus-dualpixel-6
Figure 23.2.7 (reproduced). Qualitative comparison of defocus-deblurring methods on real dual-pixel captures: the dual-pixel input recovers detail that single-image deblurring cannot Abuolaim & Brown 2020.
Video 1. Defocus deblurring using dual-pixel data (Abuolaim & Brown, ECCV 2020): the authors' talk, showing how the two dual-pixel half-images give a per-pixel defocus cue that drives depth-aware deblurring, the same signal a phone's synthetic depth of field exploits.

Failure modes⧉

optional

The common failure modes are easy to recognize once you know what to look for (Figure 23.2.8). The first is the edge halo: a matting error around fine, high-frequency boundaries (wind-blown hair, a frizzy sweater, backlit foliage) where the matte cannot decide subject from background and leaves either a soft halo of background bleeding into the subject or a fringe of sharp subject stranded in the blur. The second is the flat, shapeless blur: a kernel whose profile does not match the intended pupil, compounded by lost highlight radiance in a clipped input, so the background looks smeared rather than defocused. The third is the wrong subject (the segmentation grabs the railing instead of the person, or sharpens the coffee cup and blurs the face), a depth/segmentation failure that no amount of pretty bokeh can rescue. The fourth is foreground bleed: a sharp hand or shoulder closer than the focal plane gets softened into the background because the estimated defocus magnitude or subject matte is wrong; foreground defocus itself is physically legitimate.

fig-portrait-failure-modes
Figure 23.2.8 (reproduced). A gallery of portrait-mode tells. Four crops, each a classic failure: (1) a matting halo around wind-blown hair, where the soft matte leaks background into the strands; (2) the wrong subject blurred, a foreground railing left sharp while the person behind it is softened, the segmentation having grabbed the rail; (3) a flat, shapeless Gaussian blur with dim, structureless highlights instead of bokeh disks; (4) foreground bleed, a sharp hand reaching toward the camera mistakenly blurred into the background by a depth error. Each crop is annotated with the failing pipeline stage.

The chapter's main point is simple: portrait mode is a depth-estimation + matting + plausible-blur stack, and a composited result is only as good as its weakest stage, which in practice is usually the matte at fine edges. The depth-to-blur circle follows an idealized model; the bokeh can be made gorgeous; but a single misjudged strand of hair or a railing mistaken for a subject undoes all of it, because the eye polices silhouettes ruthlessly. This is the deepest lesson of the chapter, and it generalizes far beyond portrait mode to every composited, multi-stage computational image: the picture inherits the failures of its frailest component.

💡 The big lesson

Defocus is not a 2-D convolution, and "portrait mode" is not a blur filter. A real lens blurs the scene in depth, with the blur radius set by each point's distance from the focal plane and with occlusion bookkeeping at every silhouette. Faking that look is therefore a depth + matting + plausible-blur pipeline, not a single Gaussian: estimate where each pixel is, matte the subject cleanly, grow an aperture-shaped, energy-preserving blur with the circle-of-confusion law $c(z)\propto|1/z_f - 1/z|$, and composite in depth order so the sharp subject occludes the blurred background. The result is only as convincing as its weakest stage (usually the matte at hair and fine edges), and it can never fully equal real optics, because the background hidden behind the subject's softened silhouette was never captured and must be guessed.

Focal stacks and depth of field extension⧉

in the book↗

A single photograph can only be sharp over a limited slab of depth. The optics chapter made this precise: only scene points whose blur disc stays inside an acceptable circle of confusion count as in focus, and that acceptable band, the depth of field, is set by the aperture, the focal length, and the focusing distance. Stop the lens down and the band widens, but you pay twice for it: a smaller aperture lets in less light (more noise) and eventually runs into the diffraction limit, at which point sharpness falls again. So there is a floor. In macro photography, microscopy, product and jewelry shots, or a landscape that wants both a near rock and a far peak crisp, even the smallest usable aperture cannot hold the whole scene in focus at once. These are exactly the cases the optics chapter flagged as unwinnable in a single exposure.

The escape is not to push the optics harder but to change axis. Instead of committing to one focus distance at the instant of exposure, capture a stack of frames focused at different distances, and merge them, keeping each output pixel from the frame in which that scene point is sharpest. As the focus sweeps front to back, the thin in-focus slab marches through depth, so every surface in the scene is sharp in some frame. Stitch the sharp pieces together and you get an all-in-focus (extended depth-of-field) image that no single exposure could have taken.

It is one idea you have already met three times. The merge is a per-pixel selection: measure local sharpness, take the argmax across the stack, and the good merge is the same graph-cut label choice plus gradient-domain blend that hid the seams in panorama stitching and object compositing. We will build the simple selection algorithm first, upgrade it to the principled Photomontage version, and close on the capture hardware and the one trap that quietly sabotages a naive stack: refocusing the lens changes the magnification. Every merge below assumes the frames are already registered (pixel-aligned); the hardware section at the end explains why that assumption is non-trivial because refocusing subtly rescales the frame, and how to restore it.

💡 Big lesson ((L13.1) · capture the full set, decide later)

Instead of fixing the focus distance at the instant of exposure, record a whole stack of focal planes and choose per pixel afterward. The slogan: focus stacking is to the focus distance what HDR bracketing is to exposure and what the light-field camera is to the aperture, reconstructing the depth dimension the medium loses (Chapter 5.8, Photographic representation and its limits). Defer an irreversible capture decision out of the moment of exposure, paying with more data and a harder reconstruction (a per-pixel merge) for an all-in-focus image no single shot could make. This is the same move as HDR (the exposure axis) and panorama (the viewpoint axis); here the axis is focus. (Registered as L13.1; it first appears in this part's introduction, and the light-field / plenoptic camera in Part 33, Computational optics and coded imaging is the same idea for the focus axis, a special case. Here it recurs on the focus axis.)

Why limited depth of field is the problem⧉

optional

Being precise about what we are fighting also tells us why a naive merge struggles. From Part 22, Compound lenses, and aberration correction: only objects within the depth of field image inside an acceptable circle of confusion; everything nearer or farther blurs. The band grows as you stop down; a bigger $f$-number $N$ means more depth in focus, but a small aperture means less light and, past a point, diffraction that softens the whole image again. There is no aperture at which a deep macro scene comes out fully sharp. Where this bites hardest is macro (a bug or a flower at close range), microscopy, product and jewelry work, and landscape that wants a near foreground and a far horizon both crisp.

One caveat from optics matters for everything that follows: defocus is not a single convolution of the image. The blur radius depends on scene depth, not on output-pixel location, and at depth edges occlusion intervenes: a sharp foreground edge sits in front of a blurred background, and which one a pixel belongs to flips abruptly. This is why a naive blend struggles precisely at depth boundaries, and why the good merge needs coherent seams rather than a smooth cross-fade.

A simple algorithm: sharpness = local high-frequency energy, then argmax⧉

in the book↗

The core idea is a one-line answer to "which frame is sharpest here?" A textured region often carries more local high-frequency energy near focus: crisp edges and fine texture. Defocus is a low-pass blur; it destroys high frequencies. So measure, per pixel and per frame, how much high-frequency content sits in a small window, and at each output pixel pick the frame that has the most.

Concretely, take the band-pass / high-frequency component of frame $I_k$, such as a Laplacian, a high-pass filter, or one band of a pyramid, and accumulate its energy over a small window $w(p)$ around the pixel:

$$ s_k(p) = \sum_{q \in w(p)} \lVert \nabla I_k(q) \rVert^2 . $$

Read this back: the sharpness of frame $k$ at pixel $p$ is the local high-frequency power, squared gradient (or squared Laplacian) summed over a neighborhood. The window matters: a single pixel's gradient is too noisy a vote, so we pool a small patch's worth of high-frequency energy into one sharpness reading (Figure 23.3.1).

There is one subtle step here that trips people up. You must square (or take the absolute value) before you average. The raw high-frequency signal swings positive and negative: crossing an edge it runs $+ \to 0 \to -$. Its local average is therefore near zero by construction: the low frequencies, which carry any net offset, were exactly what the high-pass removed. Smoothing the signed band-pass can cancel positive and negative responses instead of measuring their magnitude. Square it first and every value is positive, so the local (Gaussian) average now correctly reads "there is detail here." This is the same reason variance, not the mean of a zero-mean signal, measures activity (Figure 23.3.2).

With a per-frame sharpness map in hand, the all-in-focus image is the per-pixel argmax: at each pixel, copy from whichever frame was sharpest:

$$ k^*(p) = \arg\max_k s_k(p), \qquad I(p) = I_{k^*(p)}(p) . $$

With calibrated focus distances and reliable texture, the selection map $k^*(p)$, "which focal plane was sharpest here," supplies a coarse depth estimate, since each frame corresponds to a known focus distance. Recovering depth this way is shape-from-focus Nayar & Nakagawa 1994, and it ties the focal stack to depth estimation: the same sharpness-argmax that builds the all-in-focus image also sketches the scene's geometry.

A hard argmax, though, is noisy and seam-ridden. At a pixel where two frames are nearly tied, the winner flips on a coin, and neighboring pixels can end up sourced from wildly different frames (salt-and-pepper switching). Two softening fixes from the slides, both about weighting the best frame more heavily while staying spatially coherent:

Beyond reweighting, it helps to spatially regularize the choice itself: smooth the sharpness maps $s_k$, or smooth the label field, so neighboring pixels tend to draw from the same frame. This "spatial coherence in the choice of pixels" is the right instinct, and it is exactly what the advanced method makes principled instead of ad hoc (Figure 23.3.3).

fig-focalstack-capture
Figure 23.3.1 (reproduced). Why one exposure is not enough, and how the stack fixes it. At a single aperture only a thin slab of depth falls inside the acceptable circle of confusion, so the subject is sharp in one band while foreground and background mush into blur; stopping down to f/16 widens the slab but cannot cover the whole scene, and diffraction softens everything past the smallest usable aperture. The cure: the same scene shot as $N$ frames focused front to back, with the thin in-focus slab sweeping through depth across the sequence, so every surface is sharp in some frame. An inset contrasts the two ways to sweep focus: refocus the lens (camera fixed, focus distance changed) versus translate the camera on a rail along the optical axis. The merge keeps each pixel from the frame where it is sharpest.
fig-focalstack-sharpness
Figure 23.3.2 (reproduced). Building the sharpness map. Left to right for one input frame: (1) the frame; (2) its band-pass (signed, shown red for positive / green for negative), which swings through zero; (3) the band-pass squared, now all-positive; (4) the squared band-pass Gaussian-smoothed = the per-pixel sharpness map $s_k$, bright where the frame carries local detail. This is the pipeline behind $s_k(p)=\sum_{w}\lVert\nabla I_k\rVert^2$.
fig-focalstack-argmax-composite
Figure 23.3.3 (reproduced). Selection and softening. Side by side: the per-pixel argmax selection map (a random color per source frame, so it reads as a coarse depth map / which-frame-won image) and the resulting all-in-focus composite. A second pair contrasts exponent-1 weighting (smoother but softer, blurry frames leak in) against exponent-4 weighting $w_k=s_k^4$ (near-argmax, the sharp winner dominates), showing the latter is subtly but visibly crisper.
fig-focalstack-why-square
Figure 23.3.4 (reproduced). Why square before averaging. A 1-D edge: the band-pass response swings $+\to 0\to -$ across the edge, so its raw local average is about zero: smoothing it directly reports "no detail." Squaring makes the response all-positive, so the local average now tracks "there is detail here." The same argument justifies using squared gradient / Laplacian power as the sharpness measure.

The more advanced method: Interactive Digital Photomontage (graph-cut + Poisson)⧉

optional

The weighted blend has a built-in flaw, and it lives exactly where the optics warned us it would: at depth edges. Because the blend mixes frames wherever sharpness is close, near a depth boundary it averages a sharp foreground against a blurred background (and vice versa), leaving residual blur, ghosting, and visible transitions. Occlusion means the "right" answer flips abruptly across that boundary, but a smooth weighted sum cannot flip abruptly. What we actually want is a clean per-pixel choice that is spatially coherent, joined by an invisible blend only at the boundaries where the choice changes.

This is precisely the cut-then-reconstruct problem this part has already solved twice, and the focal-stack merge is just one application of the general tool: Interactive Digital Photomontage Agarwala et al. 2004. It is a two-stage pipeline, and both stages are chapters you have already read.

Box: Interactive Digital Photomontage (the cut-then-reconstruct compose)

Agarwala, Dontcheva, Agrawala, Drucker, Colburn, Curless, Salesin and Cohen (2004) frame compositing a stack of registered images as: (1) choose a source label per pixel by minimizing a discrete labeling energy with a graph cut (L10.5, Chapter 10.9, Seam optimization), and (2) hide the residual mismatch across the chosen seams with a gradient-domain (Poisson) blend (L10.4, Chapter 10.8, Poisson image editing). The data term encodes what you want, here "the sharpest frame", and the smoothness term encodes where a switch is cheap. All-in-focus extended depth of field is one of the paper's showcase applications; the same machinery does best-exposure HDR-like selection, group-photo "best face" merging, and clean-plate background extraction. This is the L13.1 decide-later merge given its principled form: the energy is the design; the optimizer is off the shelf.

Stage one, graph-cut label selection (L10.5, Chapter 10.9, Seam optimization). Assign each pixel $p$ a source-frame label $\ell_p$ (which frame it copies from) by minimizing a discrete energy over the whole label field,

$$ E(\ell) = \sum_p D_p(\ell_p) \;+\; \sum_{p \sim q} V_{pq}(\ell_p, \ell_q) . $$

The data term $D_p$ prefers the sharpest frame at $p$, for instance $D_p(\ell) = -\,s_\ell(p)$, so high sharpness is low cost. The smoothness term $V_{pq}$ is a seam cost: it penalizes changing the label between neighbors $p$ and $q$ in proportion to how much the two frames disagree there, so the cut prefers to switch along matching, low-contrast boundaries where the transition will be invisible. For two labels and a submodular pairwise energy, a graph cut can find the global optimum. A stack has many labels: alpha-expansion uses binary moves to reduce the energy and generally yields a local move optimum, not an exact global multi-label solution.

Stage two, gradient-domain (Poisson) blend (L10.4, Chapter 10.8, Poisson image editing). Even the best label map leaves small exposure, color, and level mismatches across each seam. So instead of copying each region's pixels, copy its gradients, and reconstruct the image whose gradients best match by solving the Poisson equation $\nabla^2 f = \operatorname{div}\mathbf{v}$. With boundary values or another intensity anchor, the Poisson solve reconciles the selected guidance gradients in least squares. It can reduce level seams but does not guarantee correct gradients, eliminate occlusion halos, or preserve every original color (Figure 23.3.5).

This is the same two lessons, twice over: cut where it is cheap (L10.5 graph cut), then reconstruct in the gradient domain (L10.4 Poisson). It is the identical compose used for panorama blending and object compositing earlier in this part; focal-stack all-in-focus is just that pipeline with "sharpest frame" plugged in as the data term. In practice real macro montages stack tens of frames (fifty-five is not unusual) and the graph cut handles many labels without complaint. Commercial tools such as Helicon Focus, Zerene Stacker, and Photoshop's Auto-Blend Layers address focus stacking, but should not all be described as implementing this exact graph-cut-plus-Poisson pipeline. For example, Helicon Focus documents contrast-weighted averaging, depth-map selection, and pyramid-based methods.

fig-focalstack-photomontage
Figure 23.3.5 (reproduced). Simple blend versus Photomontage. The same focal stack merged two ways. Weighted-sum blend: at depth boundaries the mix of a sharp and a blurred frame leaves ghosting and residual blur, the non-convolution / occlusion problem made visible. Graph-cut + Poisson (Agarwala et al.): a coherent label map cuts along low-contrast boundaries and a gradient-domain blend hides the residual mismatch, giving a clean, seamless all-in-focus result. The contrast is sharpest exactly at depth edges.

Capturing the stack: hardware, and the magnification trap⧉

optional

There are two ways to sweep focus across the stack, and they differ in their geometry, which matters for the merge.

fig-macro-rail
Figure 23.3.6 (reproduced). Capturing a focal stack: a motorized macro rail. A stepper motor drives a lead screw that slides the camera along the optical axis in precise, repeatable increments, shooting one frame per focus slice. In macro the depth of field is a fraction of a millimeter, so no single frame is sharp throughout; the rail steps the focus plane through the subject and the frames are merged into one all-in-focus image. Translating on a rail (rather than refocusing the lens) avoids the magnification change, though it introduces a small parallax shift instead. (CogniSys StackShot.)

Now the trap, an important practical issue the slides mention briefly. Refocusing changes magnification. With whole-lens extension, focusing closer moves the lens away from the sensor and the image scale grows: the same scene fills a slightly larger fraction of the frame, so the field of view narrows. Internal-focusing lenses can change effective focal length and pupil position as well, so the direction and amount are design-specific. The frame "breathes" in or out as the focus runs through the stack, which means the frames in a focus sweep are not pixel-aligned: a frame focused at infinity and a frame focused up close show the same scene at slightly different scales.

Refocusing rescales the frame: register before you merge

Because refocusing changes magnification, the frames of a focus sweep are at slightly different scales. If you compute sharpness and select across mis-registered frames, the all-in-focus merge stitches detail that does not line up and you get double edges: a ghosted, fattened look along every contour. You must estimate a per-frame scale (often a near-pure zoom about the optical axis) and register the frames before measuring sharpness and selecting. Translating on a rail has a different but related geometry (a perspective / parallax shift, and the slides note it can even change the viewpoint slightly), so it may need a fuller alignment, not just a scale. This is the same align-then-merge discipline that HDR and panorama insisted on earlier in this part: register first, combine second (Figure 23.3.9).

Single-exposure alternatives exist: focus-sweep methods scan focus during one exposure, recording an integrated blur that generally requires a matched reconstruction. Integration alone does not select the sharp contributions and produce an all-in-focus image. And there is a dual escape that this chapter keeps pointing to, the light-field (plenoptic) camera Ng 2005 samples position and direction in one shot, trading finite sensor samples between spatial and angular resolution and lets you refocus after capture computationally. A captured light field can be refocused into a whole focal stack and then merged with exactly the Photomontage pipeline above, which is why the two ideas are duals: the focal stack defers focus by capturing frames, the light field by capturing rays. Both are L13.1 on the focus axis, and both are taken up in Part 33, Computational optics and coded imaging. (Time- and light-efficient capture of focal stacks specifically is analyzed by Hasinoff & Kutulakos 2009.)

A light field is just the set of all those rays, indexed by where each ray crosses two planes (two-dimensional aperture coordinate $u$ and two-dimensional image coordinate $s$; a diagram often shows a one-dimensional slice), so the captured data is a function $L(u,s)$ over rays rather than a single image (Figure 23.3.7). Given it, refocusing is the focal stack's dual: shift each aperture view by an amount proportional to its position and average (shift-and-add), and whichever depth's disparity the shift cancels comes into focus, giving a whole focal stack synthesized from one capture, refocusable after the shutter (Figure 23.3.8).

fig-lightfield-uv
Figure 23.3.7 (reproduced). The two-plane parameterization of a light field. A ray is pinned down by where it pierces two planes (an aperture coordinate $u$ and an image-plane coordinate $s$) so the whole light field is a function $L(u,s)$ over rays (here the 2-D $u$–$s$ slice). Drag the $u$ and $s$ ends of the ray and watch the point move in the $L(u,s)$ diagram: a single sensor pixel is one $(u,s)$ sample, a pinhole image is a slice at fixed $u$ (sweeping $s$ alone), fixing $s$ and sweeping $u$ instead shows one scene point as seen from every viewpoint across the aperture, and refocusing is a shear of this space. After Levoy & Hanrahan 1996 and Ng et al. 2005.
fig-lightfield-viewer
Figure 23.3.8 (reproduced). A light-field viewer, live, over a 9×9 grid of sub-aperture views. It defaults to real Lytro Illum plenoptic-camera captures (INRIA dataset), a true light-field camera, so the baseline is small and the refocus is subtle but real, and offers Stanford's wide-baseline gantry "chess" capture as a reference where the effect is dramatic. From the one capture you can, after the shutter: refocus to any depth (shift-and-add the views), choose a synthetic aperture (sum one view for an all-in-focus pinhole image, or many for shallow depth of field you can refocus at will), and shift the viewpoint by dragging the eye across the view grid to see the parallax. It is the focal stack's dual made tangible: capture rays once, decide focus and aperture later L13.1. After Ng et al. 2005; data from the INRIA Lytro Illum Light-Field Dataset (Le Pendu, Guillemot & Dansereau) and the Stanford Light Field Archive.
Video 2. Video: Light-Efficient Photography: choosing aperture and exposure across a focal stack to extend depth of field at the least cost in light and time (Hasinoff & Kutulakos 2009, Hasinoff & Kutulakos 2009), reproduced with permission.
fig-focalstack-magnification
Figure 23.3.9 (reproduced). The magnification trap. The same scene focused at infinity versus focused close: the field of view (and hence the magnification) differs, so the two frames are at slightly different scales and do not pixel-align. The caption shows that merging without correcting this produces double edges, and that estimating a per-frame scale (a near-pure zoom about the optical axis) and registering the frames first fixes it.

In CompPhotoRoom

The Focus stack merge of Chapter 8.13, A raw developer in the browser implements this chapter's simple method verbatim (band-pass, square, then smooth; sharpness-to-the-fourth weights), and its winner map doubles as the coarse depth map of shape-from-focus.

Refocusing and synthetic aperture⧉

A focal stack from one capture, and an all-in-focus image⧉

optional

The shift $k$ is continuous, so nothing stops us from sweeping it. Sweep $k$ from front to back and you generate a whole focal stack, for example front-focused, mid-focused, and back-focused images, every frame computed from the one light field you captured (Figure 31.4.3). This creates a computational counterpart of Chapter 23.3, Focal stacks and depth of field extension, with different sampling and noise limits. That chapter built a real focal stack by physically refocusing the lens between exposures, capturing $N$ frames; here we capture once and manufacture the same $N$ frames by shift-and-add. The focal stack defers focus by capturing frames; the light field defers it by capturing rays. Both are the same L13.1 move on the focus axis.

And once you have a focal stack, captured or synthesized, the rest of the machinery carries straight over. Feed the synthesized stack into the focus-stacking merge: measure local high-frequency energy per frame, take the sharpest at each pixel, and (in its principled form) cut and Poisson-blend along coherent seams. The high-exponent per-pixel sharpest selection, the photomontage of Chapter 23.3, Focal stacks and depth of field extension, collapses the whole stack into one all-in-focus image, with extended depth of field from a single exposure, limited by the captured spatial/angular bandwidth and the reliability of the focus measure. As a bonus, the per-pixel winning slope, which value of $k$ made each pixel sharpest, is a coarse depth map: the same shape-from-focus read-out, now obtained without ever moving the lens. One shutter press yields a refocusable stack, an all-in-focus image, and a depth map (Figure 23.3.8).

fig-lightfield-refocus
Figure 31.4.3 (reproduced). Refocusing by shift-and-add, on Stanford's "chess" light field. Three reconstructions from the one capture: shifted to focus the front pieces (the back blurs), shifted to focus the back (the front blurs), and, sweeping the shift to build the whole stack and keeping each pixel from the frame where it is sharpest, the all-in-focus merge with everything crisp. Each refocused frame is one value of the shift $k$; the all-in-focus image is the focus-stacking merge of Chapter 23.3, Focal stacks and depth of field extension applied to the synthesized stack. Data from the Stanford Light Field Archive.
fig-lfcam-14-refocus
Figure 31.4.4 (reproduced). Digital refocusing on a real plenoptic capture. From a single hand-held exposure, shift-and-add reconstructs the same scene focused at different depths: change the shift $k$ and the plane that comes into focus moves front-to-back through the scene, the rest dissolving into blur, all decided after the shutter, from the one light field the camera recorded. This is the result on a real camera, not a synthetic dataset: the result that makes a plenoptic camera worth its resolution cost. Ng et al. 2005
fig-lightfield-viewer
Figure 23.3.8 (reproduced). A light-field viewer, live. It defaults to real Lytro Illum plenoptic-camera captures (INRIA dataset), a true light-field camera where the small baseline makes the refocus subtle but real, and offers Stanford's wide-baseline gantry "chess" capture as a reference where the effect is dramatic. From the one light field you can, after the shutter: refocus to any depth (shift-and-add the sub-aperture views), choose a synthetic aperture (one view for an all-in-focus pinhole image, many for shallow depth of field you can refocus at will), and shift viewpoint by dragging the eye across the view grid to see the parallax. It opens with a wide aperture, so, exactly like a camera, you click anywhere to focus there: a one-time shape-from-focus pass over the focal sweep builds a per-pixel focus (depth) map (toggle it on to see it), and the click just looks up the depth and snaps the focal plane to it. It makes the focal-stack dual tangible: capture rays once, decide focus and aperture later L13.1, and the focus map is the same depth-from-focus read-out the chapter's all-in-focus merge produces. After Ng 2005; data from the INRIA Lytro Illum Light-Field Dataset (Le Pendu, Guillemot & Dansereau), decoded from the raw Lytro captures by the pipeline in the appendix Chapter 45.23, Reading a Lytro light field, and the Stanford Light Field Archive.

A plenoptic camera hands you, after the shutter, an image with the light-gathering and shallow depth of field of the full aperture, because you sum every sub-aperture view and keep all the photons, but with the freedom to place the focal plane anywhere within the depth of field of a single sub-aperture, whose effective pupil diameter is roughly the full aperture diameter divided by $n_a$, the number of angular samples across the pupil. Increasing $n_a$ can extend usable refocusing while reducing the simplest per-view spatial sample count for a fixed sensor. Here $n_a$ is a sample count; $k$ remains the refocus shear. This is the spatial↔angular trade once more. Two reconstructions sit on top, and they differ in kind: refocusing is linear: shift-and-add is a plain weighted sum of recorded rays, so it is cheap, stable, and well behaved; all-in-focus is non-linear: it is a per-pixel pick the sharpest frame selection (the focus-stacking merge of Chapter 23.3, Focal stacks and depth of field extension), data-dependent and therefore more fragile.

Noise accounting must compare the same output area and exposure. If a reconstructed pixel sums $n_a^2$ independent detector samples with total expected signal $S$ electrons and read-noise variance $\sigma_r^2$ per sample, its shot-plus-read variance is $S+n_a^2\sigma_r^2$. Summing retains their collected photons, but does not erase repeated read noise, optical losses, or resampling correlations. A single angular view uses only part of the available light. Focus selection is also noise-sensitive, though it may operate on refocused sums rather than on individual sub-aperture views. The spatial/angular budget and the photon budget are related through the hardware; resolution is not itself a photon count.

Synthetic aperture: an aperture the size of a room⧉

optional

Everything so far used the rays inside one lens, so the synthetic aperture could be no wider than that lens. Replace the lens with a camera array, a grid of full cameras spread over a wide baseline, from Chapter 31.2, Light field cameras, and run the same shift-and-add, and the effective aperture becomes as large as the whole rig. The depth of field that results is extraordinarily shallow: a tiny slab in sharp focus, everything else dissolved into a strong blur. That sounds like a defect until you see what it buys.

Align the array (choose the shift $k$) to the plane of a subject hidden behind an occluder: foliage, a chain-link fence, a milling crowd. The subject, on its focus plane, has its rays brought into agreement across all the cameras, so their intensities reinforce one another and the subject becomes clearer. This is radiance averaging, not coherent optical interference. The occluder is at the wrong depth, so each camera sees it displaced differently; across the wide baseline a leaf that blocks one camera's view of the subject does not block the next camera's, and when you average all the views the occluder, never aligned, spreads into a veil whose strength depends on how many views it blocks. A point hidden from every camera remains unobserved; ordinary averaging does not remove all foreground attenuation or color contamination. The wide synthetic aperture has a depth of field so thin that the foreground is blurred almost out of existence while the plane behind it stays sharp. This is synthetic-aperture photography for seeing through occlusion, from Levoy et al. 2004 and Vaish et al. 2004, the dramatic extreme of the same shift-and-add we used to refocus a single lens, and a relative of the dynamically reparameterized light fields of Isaksen et al. 2000, which made exactly this choice of focal plane and aperture a control you steer after capture (Figure 31.4.6).

fig-synthetic-aperture-seethrough
Figure 31.4.6 (reproduced). Synthetic-aperture see-through. A wide camera array imaging a subject behind an occluder, such as foliage, a fence, or a crowd. Run shift-and-add aligned to the subject's depth plane: its rays agree across all the cameras and it resolves sharply, while the occluder, at the wrong depth and displaced differently in every view, never aligns and averages into a faint haze the subject shows through. The synthetic aperture spans the whole rig, so its depth of field is thin enough to blur the foreground nearly out of existence. After Levoy et al. 2004 and Vaish et al. 2004.

A last connection. The light field is the common substrate under all the multiple-exposure ideas of Multiple exposure imaging: HDR varied exposure, panorama varied viewpoint, and focal stacking varied focus. A camera array can vary all of them at once across its many apertures. That generalization, from one synthetic aperture to many apertures fused for speed, dynamic range, and resolution, is the subject of the next chapter.


Wavefront coding⧉

Why you cannot just deblur defocus⧉

optional

The obvious idea is to skip the clever optics entirely: take an ordinary photo with its shallow depth of field, then deconvolve the out-of-focus regions back to sharpness. Defocus is a blur; blur is (locally) a convolution; deconvolution inverts a convolution. Why not just do it? Two problems sink the naive version, and understanding them is what motivates everything that follows.

Problem 1: the blur is not shift-invariant: it depends on depth. A defocused point images to a disc, the circle of confusion, whose diameter grows with how far the object sits from the focus plane. A scene with near and far objects therefore carries many blur sizes at once: the kernel is different at every pixel, set by that pixel's depth. Deconvolution wants one known kernel applied everywhere; defocus gives it a different unknown kernel everywhere. (There are also nasty occlusion effects at the boundary between a sharp foreground and a blurred background, where the blurred light bleeds across the edge.) Worse, to pick the right deconvolution kernel per pixel you would need a depth estimate or a joint depth-and-image reconstruction. That is itself a hard problem. Defocus is simply not the clean shift-invariant convolution that deconvolution is built to undo.

Problem 2: the blur kills information. Even where the blur is a known convolution, defocus is a particularly destructive one. A defocus blur is roughly a flat disc, and the Fourier transform of a disc has zeros: whole rings of spatial frequencies where the blur's response is exactly nothing. A frequency the blur multiplied by zero is gone; no deconvolution can divide it back, because dividing by zero recovers nothing but amplified noise. The out-of-focus disc does not merely scramble the high frequencies, it erases some of them. So even in the best case, deblurring ordinary defocus means fighting a kernel whose frequency response dips to zero, exactly where the information you want lived.

💡 The two obstacles to deblurring defocus

Ordinary defocus resists deblurring for two reasons. (1) Its blur kernel varies with depth, with a different unknown circle of confusion at every pixel, so it is not the single shift-invariant convolution deconvolution needs (and recovering the per-pixel depth is itself hard). (2) Its blur destroys information: a defocus disc has zeros in its frequency response, killing whole bands of spatial frequency that no deconvolution can restore. Wavefront coding attacks both by re-engineering the optics so the blur becomes depth-invariant and zero-free.

Human factors and the art of photography⧉

Macro photography⧉

optional

Macro photography means shooting small subjects at high magnification, such as an insect, a flower's stamen, or a snowflake, at life-size (1:1), where the subject projects onto the sensor at its true size, or greater. It is technically demanding for one dominant reason.

The central problem is depth of field. At 1:1 the in-focus band is on the order of millimeters even with the aperture stopped well down. Focus on a dragonfly's eye, and its wings are already a blur. Everything in macro technique is a response to this. You can stop down (f/8–f/16 and beyond) to deepen the band, but only so far, because at very small apertures diffraction starts softening the whole image, and at high magnification that ceiling is real and close, so brute-force stopping down runs out fast. The computational escape is focus stacking: shoot a stack of frames at stepped focus distances and combine the sharp slice from each (this is the focus-stacking story of the multiple-exposure chapter, and an instance of the capture-everything-decide-later idea; see L13.1). For the same subject framing, f-number, and final display size, a smaller sensor uses lower image magnification and can give more depth of field. That advantage is not free: diffraction and noise also matter, and at the same 1:1 reproduction ratio the sensor covers a smaller subject area.

Working distance versus magnification is the other thing to understand, and it surprises people. A longer macro focal length gives you more working distance, meaning more physical room between the front of the lens and the subject, at the same magnification. That extra room matters enormously, because at macro distances the lens itself is so close it shadows the subject and the subject is so close it spooks. Going longer does not change the depth-of-field band: at the same magnification, effective f-number, and acceptable circle of confusion, depth of field is approximately independent of focal length; pupil magnification can change the result for real lenses (again, the image-formation chapter). So a 100 mm and a 180 mm macro lens framing the same bug at 1:1 give the same razor-thin focus band; the longer one just lets you stand back.

The gear follows from this: a true macro lens, or cheaper routes such as extension tubes (spacers that let any lens focus closer), a reversed lens, or close-up diopters (filters that act like reading glasses), plus a focusing rail to step focus precisely for a stack. The light is its own challenge: the subject is so close that the lens shadows it, so macro shooters use a ring flash or twin flash around the lens, with diffusers, and a tripod for anything that will hold still. Finally, macro 3D via hypostereo uses a stereo pair shot with the two viewpoints spaced only millimeters apart (a tiny baseline), which gives natural-looking depth on a subject just centimeters from the lens, where a normal eye-spaced baseline would exaggerate it into a cardboard cutout (cross-reference the stereo chapter).

Recap: big lessons in this lecture

We will lean almost entirely on ray (geometric) optics, because nearly every source and interaction we meet is incoherent, and incoherent imaging is linear in intensity. The one piece of the wave picture we hold onto is that the physical color of light is its spectral distribution, the energy it carries at each wavelength. The exceptions to the ray picture are narrow: light squeezed through a small hole (diffraction), a thin film (interference), or a fine structure (structural color), and even structural color we can usually fold into absorption and go on treating the light as rays. Ray optics and incoherent imaging are linear, with one standing catch: the quantities are always positive, so we can add light but never subtract it. Coherent light and full wave optics, where amplitudes add and can cancel, come back only for the advanced topics of metalenses, lensless cameras, and holography, and the particle picture we keep mostly for modeling noise. So most of the time we will picture light as a set of rays traveling in straight lines through homogeneous media, each carrying a radiance that is itself a distribution over wavelength. With that, we have followed light from its source, off a surface, and to the edge of the camera; the chapters that follow take up how eye and camera turn that light into color and into an image.

💡 Big lesson (L2.10) — the smaller the aperture, the more diffraction blurs

Counter to ray-optics intuition, a smaller aperture spreads light more: the diffraction blur (the Airy disk) grows as $\sim\!\lambda N$ with f-number, so stopping down past a point softens the image instead of sharpening it. The flip side is the rule behind every instrument that must resolve fine detail: only a large aperture can diffract little and resolve finely, which is exactly why microscopes and telescopes are built around large lenses and mirrors, and why a phone camera's tiny aperture hits a hard resolution wall it cannot pass. It is the optical cousin of "you can't sample your way past Nyquist."

fig-diffraction-wave-sim
Figure 2.1.46 (reproduced). Diffraction, simulated. A live 2-D solution of the wave equation: a plane wave arrives from the left and passes through a single slit in an opaque barrier. Before the slit the wavefronts are flat; after it they bend into expanding arcs and spread, and the time-averaged intensity on the far screen forms the single-slit pattern, a broad central lobe flanked by weaker side lobes. Narrowing the slit (or lengthening the wavelength) widens the spread. This is the near-field (Fresnel) pattern at that fixed screen distance, not the textbook far-field sinc²: a narrow slit is already effectively in its far field and shows one broad lobe, while a wide slit still roughly projects its own width, fringed by edge diffraction; the region left of the slit also shows genuine standing-wave interference between the incoming wave and the part reflected off the barrier. Interactive: press play and vary the slit width and wavelength to watch the wave evolve.
💡 Big lesson (L2.16) — zooming in is not the same as moving closer

You can make a subject fill the same fraction of the frame either by zooming in or by stepping closer, and at that one depth the two give the identical magnification. But magnification falls off with distance, so everything at other depths behaves differently. Changing focal length rescales the whole projected image by a single factor (it is the pixel stage $K$, the "crop = zoom" lesson again), preserving every near-far size ratio; changing your distance rescales near and far by different factors, because each object's magnification depends on its own depth. Step close and the near looms while the far recedes; zoom from afar and the background stacks up "compressed" behind the subject. So relative near-far size (what we call perspective or compression) is set by viewpoint (distance), not by the lens; the focal length only chooses how much of that view to crop. The dolly zoom below is this lesson made vivid.

fig-dolly-zoom-sim
Figure 2.2.23 (reproduced). The dolly zoom (interactive). A 3-D scene with a subject in front of a background; one control couples focal length and camera distance so the subject is always framed the same size. Slide it and the subject holds while the background dramatically expands (wide + close) or compresses (long + far), Hitchcock's Vertigo effect, and the cleanest proof that "compression" is a property of viewpoint, not of the lens. (3-D models generated with Meshy AI.)
💡 Big lesson (L2.17) — focal length does not specify the field of view without a sensor size, hence the 35 mm equivalent

The field-of-view-depends-on-sensor-size lesson (L2.12) carries straight over to a real lens: for a fixed focal length $f$, the field of view still follows $\text{FOV}=2\arctan(\text{sensor}/2f)$, so the same lens is wide-angle on a big sensor and telephoto on a small one: the smaller sensor simply crops the projected image into a narrower view. A focal length in millimeters is a real property of the lens, but on its own it does not specify the field of view: you have to name the sensor too. That is why focal lengths are quoted as a 35 mm- (full-frame-) equivalent: the focal length that would frame the same way on a $24\times36$ mm sensor. Concretely, a phone's main camera has an actual focal length of only about 6 mm, but on its tiny (~1/1.3-inch) sensor it frames like a 24–26 mm lens on full frame, so it is sold as "26 mm equivalent." The conversion is just the crop factor, full-frame diagonal ÷ sensor diagonal (≈ 7× for that phone), multiplying the real focal length.

💡 Big lesson (L2.25) — the f-number is the aperture diameter as a fraction of the focal length

$N = f/D$: the f-number tells you the width of the opening measured in focal lengths, not in millimeters. $f/4$ means the opening is one quarter of the focal length across. Writing the aperture this way is what makes it a portable brightness setting: because the cone of light converging on each sensor point has half-angle $\tan\theta = 1/(2N)$, the ratio alone sets the image brightness, so the same f-number gives the same exposure on any lens, whatever its focal length or physical size. The denominator is why a small number is a big opening, and the area-goes-as-diameter-squared law ($\text{light}\propto 1/N^2$) is why the stop series climbs by $\sqrt2$.

fig-aperture-fnumber-cones
Figure 2.3.14 (reproduced). Why the f-number is written as a ratio, read off the light cone. Left: the same f-number gives the same cone, and hence the same brightness, at any focal length. A short lens (aperture $D$ at distance $f$) and a long lens (aperture $2D$ at distance $2f$) have the identical $N = f/D = 4$, so their converging cones share the very same half-angle $\tan\theta = 1/(2N)$; the long lens's opening is physically twice as wide yet pours no more light onto the sensor point, because only the ratio matters. Right: at a fixed focal length, opening up (a smaller f-number) widens the cone. The light collected follows the opening's area, $\propto D^2 \propto 1/N^2$, so $f/2, f/4, f/8$ pass $1, \tfrac14, \tfrac1{16}$ of the light; halving the area (one stop) takes a $\sqrt2$ step in $N$, which is the whole reason the aperture series climbs $f/2, 2.8, 4, 5.6, 8, \dots$
💡 Big lesson (L2.27) — depth of field is set by a maximum acceptable circle of confusion

A defocused point never images as a point but as a blur disk: the circle of confusion. The depth of field is then defined as the range of distances over which that disk stays smaller than a chosen maximum $c$: inside the depth of field every point is blurred less than $c$, outside it more. The operative word is acceptable: $c$ is not a constant of nature but a judgement call that depends on the target application, the viewing distance, and the sensor (or print) resolution. A billboard read from across the street tolerates a huge $c$; a 100% crop on a 4K monitor almost none. Change the standard and the depth of field changes with it, even though the optics did not.

fig-circle-of-confusion
Figure 2.5.3 (reproduced). The circle of confusion. A point at the focus distance reconverges to a single point on the sensor (sharp). A point too far focuses in front of the sensor and a point too near focuses behind it, so each reaches the sensor as a small disk: the circle of confusion. A point is judged acceptably sharp while its disk stays under a tolerance diameter c. Depth of field widens as you stop down: a smaller aperture narrows the cone and lets more of the scene stay within the tolerance disk.
💡 Big lesson (L2.28) — depth of field scales linearly with f-number, quadratically with distance, inverse-quadratically with focal length

Away from the macro range (subject much closer than the hyperfocal distance), the total depth of field follows a clean scaling, $\text{DoF}\approx \dfrac{2\,N\,c\,s^2}{f^2}$: it grows linearly with the f-number $N$ (stop down for more), quadratically with the focusing distance $s$ (step back and it balloons), and inversely with the square of the focal length $f$ (wider for more, longer for less). These three exponents explain at a glance why a phone (tiny $f$) keeps almost everything sharp, why close focus annihilates depth of field, and why "I need more in focus" always reduces to stop down, back up, or go wider.

fig-depth-of-field
Figure 2.5.8 (reproduced). The near and far limits of depth of field. Each scene point's cone is carried to the sensor; the near-limit object focuses behind the sensor and the far-limit object in front of it, each producing a circle of confusion just equal to the tolerance c. The band between them is the depth of field, slightly asymmetric, with more depth behind the focus plane than in front. (Vertical scale exaggerated.)
💡 Big lesson (L2.29) — many approximations break in the macro regime

The convenient first-order results of this chapter (the depth-of-field scaling just above, the framing shortcut "magnification $\approx f/\text{distance}$", even the bare f-number as a stand-in for image brightness) all quietly assume the subject is far compared with the focal length. Up close (macro, at magnifications near or past 1:1) they break. The pupil magnification stops being 1, the effective f-number grows as $N(1+m)$ so you lose real light, the working distance shrinks toward the front element, and the depth of field collapses to millimeters. In the macro regime you must drop the shortcuts and return to the exact conjugate geometry (and, often, to focus stacking). It is a good reflex to ask of any optics approximation: does this still hold when the subject is this close?

💡 Big lesson (L2.30) — focus at the hyperfocal distance and everything from half it to infinity is sharp

There is a single focus setting that extracts the maximum depth of field from a lens: the hyperfocal distance $H = f^2/(N c)$. Focus there and the far limit runs all the way to infinity while the near limit sits at exactly $H/2$, so the entire scene from $H/2$ to the horizon falls inside the acceptable circle of confusion. Focusing at infinity instead throws away the whole sharp zone between $H/2$ and $H$ for nothing. It is the landscape-and-street photographer's standard move for front-to-back sharpness, and the basis of zone focusing (pre-set the focus, shoot without refocusing).

fig-hyperfocal
Figure 2.5.13 (reproduced). Hyperfocal distance. Focusing at H = f²/(N·c) makes everything from H/2 to infinity acceptably sharp, the focus setting that maximizes depth of field. Focusing at infinity instead (top) leaves the near zone H/2…H blurred and wastes it; focusing at H (bottom) reclaims it. The landscape photographer's standard move for front-to-back sharpness.
💡 Big lesson (L2.31) — near the subject, depth of field follows magnification; in the far background, the long lens wins

Two different questions get confused. Near the plane of focus, at equal magnification and equal f-number, the depth of field is essentially independent of focal length: stepping back to hold the framing gives back exactly what the longer lens took. In the distant background, the longer lens does defocus more, because what blurs a far object is the physical aperture diameter $D=f/N$, which grows with focal length at a fixed f-number. So "telephotos have shallow depth of field" is wrong about the subject and right about the background.

💡 Big lesson (L2.32) — in image space, defocus blur shrinks linearly with the sensor

Hold the framing and the f-number fixed and scale the camera down: the defocus blur of the background, as a fraction of the frame, shrinks linearly with the sensor size, because it tracks the lens's physical aperture diameter $D=f/N$ and $f$ shrinks with the sensor. So shallow depth of field is a privilege of physically large apertures (a big sensor with a big lens) and a small sensor cannot fake it optically. This is why phones have deep depth of field and must compute fake background blur (portrait mode, a later chapter): the tiny sensor shrinks every blur disk toward nothing. It is the image-space twin of "small sensor → more depth of field" above.

💡 Big lesson (L2.36) — sensor size is one dial behind field of view, depth of field, and light; the equivalences scale linearly with it, the light with its area

Almost every camera trade-off scales with the sensor's linear size, captured in the crop factor $c$ (full-frame diagonal $\div$ the sensor's). Three consequences, each with a different scaling:

  • Field of view: to match a framing, the equivalent focal length scales linearly, $f_{\text{eq}} = f \times c$ (L2.12, L2.17): a phone's $6$ mm lens frames like $\sim\!26$ mm.
  • Depth of field: at fixed framing and f-number the physical aperture diameter, and so the background blur, scale linearly with sensor size, so the equivalent f-number is $N_{\text{eq}} = N \times c$ L2.32: a phone at $f/1.8$ has full-frame's $f/12$ depth of field. Small sensors give deep, near-universal focus and little bokeh.
  • Light and noise: at equal framing and f-number the total light collected scales with sensor area ($\propto c^{2}$), so the photon count does too; photon-noise-limited SNR and dynamic range then scale with the linear dimension ($\sqrt{\text{area}}$, $\propto 1/c$) L2.38. This total-light advantage, not pixel count, is why a big sensor looks cleaner.

So the bookkeeping is: equivalent focal length and equivalent f-number are linear in sensor size; total light gathered is quadratic (its area); the SNR and dynamic-range benefit go as the linear dimension (the square root of area). One dial, three different exponents.

💡 Big lesson (L6.7) — most imaging blur is not a fully shift-invariant convolution

A convolution is an approximation when blur changes with depth, motion, field position, or wavelength. A small patch may support one kernel, but occlusion boundaries need particular care. Fixing geometry can preserve linearity in intensity even when shift-invariance is lost.

💡 The big lesson

Defocus is not a 2-D convolution, and "portrait mode" is not a blur filter. A real lens blurs the scene in depth, with the blur radius set by each point's distance from the focal plane and with occlusion bookkeeping at every silhouette. Faking that look is therefore a depth + matting + plausible-blur pipeline, not a single Gaussian: estimate where each pixel is, matte the subject cleanly, grow an aperture-shaped, energy-preserving blur with the circle-of-confusion law $c(z)\propto|1/z_f - 1/z|$, and composite in depth order so the sharp subject occludes the blurred background. The result is only as convincing as its weakest stage (usually the matte at hair and fine edges), and it can never fully equal real optics, because the background hidden behind the subject's softened silhouette was never captured and must be guessed.

💡 Big lesson ((L13.1) · capture the full set, decide later)

Instead of fixing the focus distance at the instant of exposure, record a whole stack of focal planes and choose per pixel afterward. The slogan: focus stacking is to the focus distance what HDR bracketing is to exposure and what the light-field camera is to the aperture, reconstructing the depth dimension the medium loses (Chapter 5.8, Photographic representation and its limits). Defer an irreversible capture decision out of the moment of exposure, paying with more data and a harder reconstruction (a per-pixel merge) for an all-in-focus image no single shot could make. This is the same move as HDR (the exposure axis) and panorama (the viewpoint axis); here the axis is focus. (Registered as L13.1; it first appears in this part's introduction, and the light-field / plenoptic camera in Part 33, Computational optics and coded imaging is the same idea for the focus axis, a special case. Here it recurs on the focus axis.)