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
Titles jump to the section below; ↗ opens it in the book.
Light and optics⧉
Wave effects, diffraction, and the diffraction limit⧉
optionalThe 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$.

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.

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
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.

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).

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.


Pinhole image formation and linear perspective⧉
Photography with focal length: framing, magnification, and compression⧉
optionalThe 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.
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.
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.
Photographers call a $24 \times 36$ mm image frame "35 mm," which sounds like a contradiction. The "35 mm" is the width of the film stock, including the sprocket-hole margins, not the image. Oskar Barnack, designing the first Leica, ran 35 mm cine film sideways through a still camera, giving a 36 mm × 24 mm frame. Today that size is called full frame, and smaller sensors are quoted by their crop factor relative to it: APS-C is about 1.5×, its name coming from the old Advanced Photo System (APS) film format, Micro Four Thirds about 2×, and a phone sensor much smaller still. The crop factor is just the "cropping = longer focal length" fact of Figure 2.2.11 applied to sensor sizes: a 50 mm lens on an APS-C body frames like a 75 mm lens on full frame, because the smaller sensor crops the projected image.
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).

Lens image formation⧉
Aperture and the f-number⧉
optionalFor 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.)
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).
$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⧉
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.
The circle of confusion⧉
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).
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.

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:
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
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⧉
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⧉
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.

The double cone, and the near and far limits⧉
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
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
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.
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.
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?


Hyperfocal distance⧉
There is one focus setting that wrings the maximum depth of field out of a lens. Focus at the hyperfocal distance
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.
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).
The surprising invariance⧉
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.
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.

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.

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.

Background blur beyond the focus plane⧉
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$,
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)$:
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.
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:
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.

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):
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
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.

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.

Defocus is not a blur of the image⧉
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.
Sensor size scales depth of field⧉
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.
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.

Defocus is integration over the aperture dimension of the plenoptic function⧉
optionalOne 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).

Sensors: photosites, CCD vs CMOS⧉
The impact of sensor size⧉
optionalSensor 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.

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.

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.

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.

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.
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.
Convolution⧉
Is imaging blur usually a shift-invariant convolution?⧉
optionalThis 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.
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⧉
optionalFor 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:
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⧉
optionalA 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.

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⧉
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)⧉
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:
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:
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
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:
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.
Measuring MTF in practice⧉
optionalSo 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:
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.
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.
Spot diagrams and the PSF⧉
optionalThe 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⧉
optionalEverything 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.
Field-dependent MTF: sagittal vs tangential⧉
optionalA 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.
Color, geometry, and illumination measurements⧉
optionalThe 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⧉
optionalFinally, 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⧉
optionalFocusing 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⧉
optionalEverything 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).
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
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⧉
optionalSometimes 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.
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⧉
optionalDepth 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.
Everything in this chapter assumes ordinary incoherent imaging, where an out-of-focus object still sends its light to the sensor: it merely spreads into a blur disk. The light is there, just smeared. George Barbastathis (MIT) makes the point that coherent imaging can behave qualitatively differently: arrange the system around a prepared depth, and objects at other depths contribute no light at all to the image. Out of the prepared depth the scene is not soft. It is black. The root of the difference is that incoherent imaging adds intensities, which are always positive, so every depth contributes something (a brighter, blurrier picture); coherent imaging adds complex amplitudes, so off-depth contributions can interfere destructively and cancel to zero. It reframes "depth of field" itself: incoherent optics trades sharpness for a graceful blur, while a coherent system can make depth a hard on/off gate: present or absent, not sharp or soft.
Fake (synthetic) depth of field⧉
optionalA 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⧉
optionalThe 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.
Where the depth (or subject) comes from⧉
optionalA 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.
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.
From depth to blur: the thin-lens circle⧉
optionalGiven 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:
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⧉
optionalA 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).
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⧉
optionalHere 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).
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.
Failure modes⧉
optionalThe 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.
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.
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⧉
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.
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⧉
optionalBeing 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⧉
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:
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:
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:
- Weighted sum, then normalize. Blend all frames with weights proportional to sharpness, $I(p) = \dfrac{\sum_k w_k(p)\, I_k(p)}{\sum_k w_k(p)}$ with $w_k(p) = s_k(p)$. If the sum is zero or negligible, use a defined fallback such as a nearby confident label or reference frame rather than dividing by zero. Noise and sharpening can inflate these scores, so keep exposure and processing consistent. This is smooth, but a blurry frame still leaks in and softens the result.
- Sharpen the weights with an exponent. Use $w_k(p) = s_k(p)^{\gamma}$ with $\gamma \approx 4$. The exponent pushes the blend toward the argmax (the sharpest frame dominates) while keeping a smooth transition rather than a hard switch. Subtle, but visibly sharper than $\gamma = 1$.
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).
The more advanced method: Interactive Digital Photomontage (graph-cut + Poisson)⧉
optionalThe 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.
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,
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.
Capturing the stack: hardware, and the magnification trap⧉
optionalThere are two ways to sweep focus across the stack, and they differ in their geometry, which matters for the merge.
- Refocus the lens (camera fixed, focus distance changed). This is the natural way, what an autofocus motor or a tunable / liquid lens does. You hold the camera still and step the focus from near to far. Choose steps with overlapping acceptable-focus ranges and keep exposure and illumination consistent. A focus rail instead changes viewpoint: it can introduce depth-dependent parallax that a global scale-and-shift alignment cannot remove.
- Translate the camera along the optical axis on a focus rail (for example the CogniSys StackShot, Figure 23.3.6). This is common in macro, where nudging the whole camera a few millimeters between frames is easier and far more repeatable than refocusing a macro lens.
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.
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).

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⧉
optionalThe 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).

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⧉
optionalEverything 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).
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⧉
optionalThe 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.
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⧉
optionalMacro 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.
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."

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.

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.
$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$.
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.

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.
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?
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).
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.
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.
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.
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.
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.
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.)