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

Lecture Notes 18 — Lenses 2⧉

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 · 37 sections on this page, from 12 chapters of the book
2FUNDAMENTALS OF IMAGING
5PHOTOGRAPHY
6LINEAR METHODS AND FOURIER ANALYSIS
22COMPOUND LENSES, AND ABERRATION CORRECTION
34COMPUTATIONAL SENSORS

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

Light and optics⧉

Light: rays, waves, and the spectrum⧉

optional

There is no single right answer to "what is light." Physics offers three models (Figure 2.1.1), and the trick is to pick the one that makes the question at hand easy. When we want to know where light goes, through a pinhole, a lens, or off a mirror, we treat it as a ray, a straight line obeying simple geometry. When we want to understand color, diffraction, or interference, we treat it as a wave, a periodic disturbance with a wavelength. And when we want to count light precisely, which is what ultimately limits image quality, we treat it as a stream of photons, discrete particles whose random arrival creates noise. The three pictures describe different aspects or approximations of the same physics.

fig-light-models
Figure 2.1.1 (reproduced). Three models of light. The same beam drawn three ways: as a ray (a straight geometric line, for tracing paths through lenses and pinholes), as a wave (a periodic oscillation with wavelength λ, for color, diffraction, and interference), and as a stream of particles (discrete photons, for counting light and understanding noise). Each model answers a different class of question; we use whichever fits.

The wave picture and the spectrum. Light is an electromagnetic wave, a coupled oscillation of electric and magnetic fields that travels through vacuum at a fixed speed $c \approx 3 \times 10^{8}$ m/s (about 300,000 km/s, and slower by a factor $1/n$ inside a medium of refractive index $n$). A single-frequency, or monochromatic, wave is characterized by one wavelength $\lambda,$ the distance between successive crests, or equivalently by its frequency $\nu,$ the two tied by

$$ c = \lambda \nu. $$

Visible light occupies a narrow band, roughly 400 nm (violet) to 700 nm (red), a small part of the electromagnetic (EM) spectrum that also includes radio, microwave, infrared, ultraviolet, X-rays, and gamma rays, all the same physics, differing only in wavelength (Figure 2.1.2). "Visible" is a fact about our eyes, not about our cameras: a standard silicon sensor responds to wavelengths the eye cannot see, into the near infrared beyond 700 nm and, with the right optics, into the ultraviolet below 400 nm, and computational photography can put that extra reach to work (Sensors).

fig-em-spectrum
Figure 2.1.2 (reproduced). The electromagnetic spectrum and the visible window. Wavelength runs from kilometer-scale radio waves to picometer gamma rays; the eye responds only to the narrow band from about 400 nm (violet) to 700 nm (red), shown expanded with its colors. Frequency and wavelength are linked by c = λν. Photography lives almost entirely in this thin visible slice (with occasional excursions into the near-infrared and ultraviolet).
fig-xkcd-273
Figure 2.1.3 (reproduced). xkcd #273 "Electromagnetic Spectrum", Randall Munroe, xkcd.com/273 (CC BY-NC 2.5).

Most light is not monochromatic, however. A general wave is a superposition of many wavelengths, and what characterizes it is its spectrum: the distribution of energy over wavelength. That is, each wavelength has a given amount of energy, and this distribution characterizes the physical color of light. Physical color is different from the notion of color as perceived by humans, and the link between the two is fundamental in imaging; it is developed in Chapter 3.2, Perceptual color and trichromatic vision.

Newton's prism. Newton demonstrated the decomposition of white light into its spectrum. Pass a beam of white sunlight through a glass prism and it fans out into the full spectrum: the rainbow band of pure colors. The lesson is that white light is not a pure thing being "stained" by the glass; it is already a mixture of all wavelengths, and the prism merely bends each wavelength by a different amount, spreading the mixture out. Newton proved this with his experimentum crucis (Newton 1704 (Opticks)): he isolated one pure color from the spread and sent it through a second prism, and it did not split further. The pure colors are the irreducible ingredients; white is their sum (Figure 2.1.4).

fig-newton-prism
Figure 2.1.4 (reproduced). Newton's prism experiment. White light entering a glass prism is dispersed into the spectrum because the prism bends each wavelength differently. The classic diagram: a second prism placed in the path of a single isolated color does not split it further, the experimentum crucis showing that white light is a mixture of pure wavelengths, not a uniform substance the prism colors.
fig-newton-prism-puzzle
Figure 2.1.5 (reproduced). The same experiment, rebuilt as a puzzle. Drag the two prisms and the lens, rotate and scale the selected piece with its handles, and slide the middle wall; the wall's slits appear automatically wherever the first prism's rays strike it, so you line the wall up with the spectrum rather than placing slits by hand. Set the prisms' dispersion and the lens's focal length; a hole-size slider widens the slits. Press Restart to scatter the setup, then Solution to snap it back to a working arrangement, or Show Newton's original to compare against Newton's own drawing of the experiment. Threading the spectrum through the slits, through the second prism, and onto the screen is a hands-on way to feel how dispersion, refraction, and focusing chain together: every ray keeps its single color through the second prism, the crux of Newton's experimentum crucis.

So a spectrum is simply a function: power plotted against wavelength, $S(\lambda)$. You can think of it as an infinity of channels, one per wavelength.

💡 Big lesson (L2.1) — light is a spectral distribution

Light, and the physical color it carries, is described by a spectral distribution: the power it carries at each wavelength, a function $S(\lambda)$. One wavelength is a single pure color; real light is a weighted mix of all of them. Everything downstream (how a prism fans light out, how a surface reflects it, how a sensor or an eye turns it into a perceived color) starts from this per-wavelength power.

fig-light-spectra
Figure 2.1.6 (reproduced). The spectra of real light sources. Each “white” source carries a different spectral power distribution $S(\lambda)$: daylight and tungsten are smooth Planck curves (cool and warm), a fluorescent tube adds sharp mercury lines on broad phosphor humps, a white LED is a blue spike feeding a yellow phosphor, and clear sky is daylight steepened by Rayleigh scattering. The swatch gives each source's perceived color; several read as nearly white despite very different spectra. Interactive: pick a source, or overlay them all; each spectrum also plays as a 1-D traveling wave, and a bandpass-filter slider isolates a band to show the surviving wave and its color: a narrow band gives a clean tone and a saturated hue, a wide band stays noisy and washes toward white.

Spectra come in two broad flavors. A smooth spectrum varies gently with wavelength: daylight, an incandescent bulb, the glow of any hot body. A spiky spectrum piles its power into a few narrow lines with little in between: a fluorescent tube (sharp mercury lines on a faint phosphor background), many cheap LEDs, a sodium street lamp, a laser. As we will discuss, spiky illuminants tend to be bad for photography because they single out a few wavelengths: their color rendering is poor (skin tones and saturated fabrics shift unpredictably), they defeat a single white-balance correction, and a scene under them can look sickly even though a meter calls the light white. Smooth, broadband light (daylight, tungsten, good full-spectrum LEDs) is forgiving; spiky light is treacherous. We return to this with white balance, color rendering, and the design of a camera's color filters.

Rays. The most useful everyday picture ignores the oscillation entirely and treats light as rays: straight lines along which light carries its energy. In a uniform medium a ray travels perfectly straight and changes direction only when it meets a surface, bending by refraction as it passes into glass or water and bouncing by reflection off a mirror. This is geometry rather than wave mechanics: to find where an image forms, you follow rays through the optics and see where they cross. It is a simplification, valid when the wavelength is tiny compared with the apertures and features the light meets, so that diffraction and interference are negligible, but it is the workhorse of this book. The overwhelming majority of what follows, image formation, focus, depth of field, exposure, nearly all of the optics, runs on ray optics, and often on an even simpler version of it, the paraxial thin-lens approximation. We reach for the wave picture only where it is unavoidable, for diffraction, interference, and the resolution limit; the rest of the time, light is rays.

Photons. The third picture is granular: light arrives in discrete packets called photons, and a detector, a camera pixel or a cell in the eye, absorbs them one whole photon at a time. Wave and photon are the same light seen two ways. The wave tells you where the light goes and how bright it is, and its intensity (the square of the amplitude) is really the density of photon arrivals; the photon is what actually gets counted. Each photon's energy is set by the wave's frequency, $E = h\nu$ (with $h$ Planck's constant), so frequency is color: a blue photon (high frequency, short wavelength) carries more energy than a red one. We are simplifying here by giving each photon a single frequency, one pure wavelength; a real photon is a short wave packet with a small spread of wavelengths, but the one-frequency-per-photon picture is all photography needs. In this view the oscillation is not something a lone photon waves about in flight, it is the wave property that fixes the photon's color and energy, while the wave's amplitude sets how many photons show up. And because photons arrive at random, counting a finite number of them is inherently noisy, which is the shot noise that ultimately limits how clean an image can be.

Reflection, refraction, and what happens at a surface⧉

in the book↗

A central goal of imaging is to route light through a scene to the right place on a sensor. For this, we mostly deal with three types of interactions with matter and optical elements: reflection, refraction, and diffraction (Figure 2.1.12).

fig-reflection-refraction-diffraction
Figure 2.1.12 (reproduced). Three things light does at a surface. Reflection: a ray bounces off a smooth surface with the angle of reflection equal to the angle of incidence (θᵢ = θᵣ), both measured from the surface normal. Refraction: a ray crossing into a denser medium bends toward the normal because light slows down, obeying Snell's law n₁ sin θ₁ = n₂ sin θ₂; past the critical angle, a ray crossing into a rarer medium cannot escape at all and undergoes total internal reflection (a faint reflected ray is always present). Diffraction: a wave passing a small aperture or edge spreads instead of traveling straight, through an angle θ ≈ λ/d: the narrower the aperture relative to the wavelength, the wider the spread, which is why stopping a lens down too far softens rather than sharpens an image. Reflection and refraction are the everyday cases; diffraction returns in the final section.

Reflection is the simplest: a ray striking a smooth surface bounces off so that the angle going out equals the angle coming in, both measured from the surface normal ($\theta_i = \theta_r$). That single rule explains mirrors and, as we will see, the bright highlights on shiny objects. The reflection angle does not vary with wavelength, which is why mirror optics does not generate chromatic aberrations. One constraint remains: reflection sends light back toward where it came from, so it is awkward to place a sensor there without occluding some of the incoming light. This is why telescopes and mirror (catadioptric) lenses usually carry a small secondary mirror in the middle that turns the light back the other way, through a hole in the primary, to a sensor tucked safely behind it (Figure 2.1.13).

fig-mirror-lens
Figure 2.1.13 (reproduced). Image formation by reflection instead of refraction: a mirror (catadioptric) lens seen head-on. Light enters the ring-shaped front, reflects off a large primary mirror at the back, then off the small central secondary mirror (the disc seen head-on) and out through a hole in the primary to the sensor behind. Folding the path with mirrors packs a long focal length into a stubby barrel, reflection introduces no chromatic aberration, and the blocked center is why such lenses render out-of-focus highlights as little rings ("donut" bokeh). Photograph by Frédo Durand.

Refraction is what happens when light crosses from one medium into another, such as air into glass or air into water. Light has a lower phase velocity in a medium with a higher refractive index, and the ratio of vacuum speed to the speed inside is the medium's refractive index $n$ (about 1.0 for air, 1.33 for water, 1.5 for typical glass). Because the wave slows, it bends. The reason is geometric: when a slanted wavefront reaches the boundary, the side that enters the denser medium first slows first and falls behind, so the whole wavefront pivots toward the slower side, the way a marching band wheels when the file on one end takes shorter steps (you can watch this unfold in Figure 2.1.14). The amount of bending follows Snell's law:

$$ n_1 \sin\theta_1 = n_2 \sin\theta_2. $$

In that same simulation, the plane wave's wavefronts crowd together as they cross into the slower medium (the wavelength shortens by $1/n$) while bending toward the normal, so Snell's law emerges from the wave equation rather than being asserted. It is also the entire reason a lens works; the fuller lens geometry is deferred to the Lens image formation chapter, but the bending rule is the same one here.

fig-refraction-wave-sim
Figure 2.1.14 (reproduced). Refraction as a wave effect. A live 2-D solution of the wave equation: a plane wave descends at an angle and crosses a horizontal interface into a slower medium (higher index $n$, lower half). Where the speed drops, the wavefronts crowd together (wavelength $\to \lambda/n$) and bend toward the normal: exactly $n_1\sin\theta_1 = n_2\sin\theta_2$, now emergent from the dynamics. Interactive: raise $n₂$ and the bending grows; change the incidence angle and the on-figure readout checks Snell's relation; move the wavelength slider and watch it crowd by $1/n$ in the denser medium. Press Play, or move a slider to jump to the new steady state. Companion to Figure 2.1.46.
💡 Big lesson (L2.4) — Snell's law

At a boundary between two media, light bends by $n_1\sin\theta_1 = n_2\sin\theta_2$, toward the normal entering a denser medium, away from it on the way out. This single rule is the seed of all lens optics: every focal length, every ray trace, the thin-lens equation, and every aberration is Snell's law applied at curved glass surfaces. Pair it with the fact that the index $n$ depends on wavelength (the next lesson) and you also get dispersion. Almost everything optical in this book traces back to it.

Dispersion. There is a wrinkle: the refractive index is not a single number but depends on wavelength, $n(\lambda)$, and for ordinary glass it is slightly larger toward the blue than toward the red. Snell's law then bends each color by a slightly different amount, so a single beam of white light fans out into its spectrum. This is dispersion: it is what a prism does, and what paints a rainbow when sunlight refracts through a raindrop. It is also the sharpest difference between refraction and reflection, since a mirror bends every wavelength by exactly the same angle while a lens does not. That wavelength dependence is a gift for spreading light into a spectrum and a curse for forming an image, because a simple lens focuses blue slightly nearer than red and cannot bring every color to one point at once. The resulting color fringing, chromatic aberration, is one of the central problems of lens design, and taming it, with glasses with different dispersions and lens elements of opposing optical powers, special low-dispersion glass, and more elements, is much of the long story of Part 22, Compound lenses, and aberration correction.

fig-prism-dispersion
Figure 2.1.15 (reproduced). Dispersion in a prism. Because the refractive index varies with wavelength (Cauchy's law: $n$ higher toward the blue), each color bends by a slightly different amount at each glass face, so a single white ray entering the prism fans out into a spectrum. This is just Snell's law applied wavelength-by-wavelength, the same physics behind the rainbow and behind chromatic aberration in lenses. Drag the incoming ray, or change the glass index and dispersion.

Diffraction, the spreading of a wave at a small aperture, is the third interaction, and because it sets a fundamental resolution limit it gets its own section at the end of this chapter. Reflection and refraction are naturally handled with ray optics and form the basis of lens design. Diffraction requires a wave perspective but is often a secondary issue in photographic optics, mostly boiling down to reducing sharpness when an aperture is too small.

fig-diffraction-single-slit
Figure 2.1.16 (reproduced). Diffraction at a single aperture, two ways (companion to the grating figure). Huygens wavelets (diagram): the open slit acts as a row of wavelet sources across its width w; straight ahead they are all in phase (the bright central lobe), while at the angle where the path difference across the whole width is one wavelength, w·sinθ = λ, the top half of the slit cancels the bottom half (the first dark minimum). The lobe's angular half-width is therefore about λ/w, so a narrower slit spreads light wider (and a smaller camera aperture blurs more). Full wave simulation: the same slit solved as the 2-D wave equation, the fan emerging from the dynamics. Set the wavelength and the slit width; absorbing borders keep waves from reflecting off the window.

Diffraction is not only a nuisance, though. When light meets a set of small openings, or any structure patterned at the scale of its wavelength (a diffraction grating, a fine periodic microstructure), the spreading waves interfere into strong, orderly beams, so diffraction becomes a way to route light rather than merely blur it. Like refraction it depends on wavelength, so it too separates colors, but in a different way: where glass bends blue light the most, a grating sends the longer red wavelengths to the wider angles. That opposite-signed color behavior is both an opportunity and a challenge for building optics out of diffraction, and we return to it later.

fig-diffraction-grating
Figure 2.1.17 (reproduced). A diffraction grating, two ways, sharing geometry and controls (wavelength λ, slit spacing d, and the angle of incidence θ₀). A strip on the right shows the intensity profile versus position on a distant screen: sharp peaks at the orders in the diagram, and in the wave simulation the measured intensity (the field's power, time-averaged along the screen column), which peaks near the same order directions. Huygens wavelets (diagram): each slit re-emits half-circle wavelets (successive crests color-coded, cycling through a few colors, so you can follow them), and in the directions where neighboring slits differ by a whole number of wavelengths (path difference d·(sinθ_m − sinθ₀) = m·λ) the crests line up into a straight emergent wavefront, a diffraction order. Choose which order to emphasize (0, ±1, ±2): its in-sync wavelet crests are thickened and joined slit-to-slit into that order's wavefront, with the orders 0, ±1, ±2 fanning out. Full wave simulation: the same grating solved as the 2-D wave equation, the orders emerging from the dynamics; press Play, or move a slider to jump to the steady state. In the diagram, Play moves the crests outward, and the emphasized order's wavefront travels with them. Sweep the wavelength and the orders move, longer λ diffracting to larger angles, which is why a grating spreads white light into a spectrum, dispersing the opposite way to a prism; tilt the incidence and the whole fan swings with it. Switch the illumination to white light to superimpose the visible wavelengths at once (in the wave simulation they are injected together into the field): every order but the 0th fans out into a spectrum, longer λ (red) going to the wider angle, while the 0th order stays white where all wavelengths overlap. The slit plane absorbs the incident wave rather than mirroring it back, and all four window edges are absorbing (Mur + sponge), so waves leave off-screen instead of reflecting.

Reflection versus refraction, vs diffraction for building optics. These ways of redirecting light have complementary strengths, and the trade-off runs through all of lens and mirror design. Reflection's great advantage is that it is independent of wavelength: a mirror bends every color by exactly the same angle, so it introduces no chromatic aberration. Its drawback is geometric, because it sends light back the way it came: to catch the focused image you must place a sensor in the returning beam, where it sits in the path of the incoming light and blocks part of it. That is the central nuisance every reflecting (mirror) telescope has to engineer around. Refraction has the opposite profile. It merely bends light, which then carries on in roughly its original direction, so nothing has to sit in the incoming path. But it bends different wavelengths by different amounts, so a single lens focuses the colors in slightly different places, and forcing them all back to one point takes more, and more complex, glass (the long story of Part 22, Compound lenses, and aberration correction). Diffraction is the third and most modern strategy: instead of a bulk shape (a curved mirror or a thick lens), a surface patterned at the scale of the wavelength, a grating, a Fresnel zone plate, or a metasurface, redirects light by interference. Its appeal is that it can be flat and thin, and that its dispersion runs opposite to glass, so a little diffractive structure can help cancel a lens's chromatic aberration. Its costs mirror that strength: it is even more strongly wavelength-dependent than glass, and a grating splits light among several diffraction orders, so only part of the energy lands where you want it and the rest becomes stray light. That is why diffractive elements remain a specialty, powerful for narrow-band and computational optics and for the flat metalenses of Part 33, Computational optics and coded imaging, rather than the everyday way to build a camera lens.

Reflection, refraction, and diffraction are the classical trio, but they are not the last word on steering light. Structured and complex materials can redirect it in ways a smooth surface cannot, most of them wave effects harnessed on purpose: a gradient-index medium that curves rays as they travel, a sub-wavelength metasurface that stamps an arbitrary phase profile from a flat film, a photonic microstructure whose interference sculpts the beam, or a programmable modulator that rewrites the wavefront on the fly. We meet a first taste of this in the next part, where a nano-prism disperses each pixel's colors onto separate photodiodes instead of absorbing them (Chapter 4.6, Sensing color: multiplexing strategies), and we take up the general toolkit later, among the exotic and advanced optics of the computational-optics part.

Video 1. Video: But why would light 'slow down'? (Optics puzzles), by 3Blue1Brown (YouTube).

Light-matter interaction is largely resonance⧉

in the book↗

Why does light slow in glass at all, why does the index of refraction always depend on wavelength, and why do different materials attenuate different wavelengths? It all comes down to vibration and resonance of the particles that make up matter. The wave's oscillating electric field drives the bound charges in a material, such as atoms, molecules, and electrons bound to nuclei, and like any spring-loaded mass each has a natural frequency it most readily oscillates at. This can be modeled as a so-called Lorentz-oscillator, and almost everything optical follows from it. Near a resonance frequency, the driven charges swing hard and the material absorbs strongly, draining those wavelengths from the light; the wavelengths a material happens to absorb (and so remove from what it transmits or reflects) are exactly what give it its color. The same driven-charge picture runs far below light too: a microwave oven cooks by driving the water molecules in food with an oscillating field they cannot quite keep up with, and that lag turns into heat (dielectric loss, the low-frequency cousin of optical absorption). Away from resonance the charges still respond, just out of step, and that lag is what slows the wave, so the refractive index $n$ is itself a resonance effect. Because each wavelength sits a different distance from the nearest resonance, $n$ varies with wavelength; this is dispersion, $n(\lambda)$, and it is behind the prism fanning out a spectrum (Figure 2.1.15), the colors of a rainbow, and the chromatic aberration that plagues real lenses. That consequence matters: because every glass disperses, a simple lens focuses blue and red at slightly different distances, and dispersion goes on to shape much of the challenge of lens design: the whole craft of combining crown and flint glasses into achromatic and apochromatic doublets, and the modern fight against chromatic aberration in fast lenses, exists to fight exactly this $n(\lambda)$ (developed in the Optics part). The resonance picture can be explored directly (Figure 2.1.18): the bound electron is driven at different frequencies, and the absorption peaks at resonance while the refractive index swings through its normal-then-anomalous dispersion.

💡 Big lesson (L2.5) — every material disperses

The refractive index is not a constant: $n(\lambda)$ depends on wavelength: in ordinary glass it rises toward the blue, so blue bends more than red. Because of this you cannot route every wavelength the same way with a single refraction: a prism fans white light into a spectrum, a raindrop makes a rainbow, and a simple lens focuses blue and red at slightly different distances: chromatic aberration. Much of the craft of lens design (combining crown and flint glass into achromatic and apochromatic groups) exists to fight this one fact. Dispersion is not a defect of cheap glass; it is built into how matter and light interact.

fig-lorentz-resonance
Figure 2.1.18 (reproduced). Light–matter interaction is a driven resonance. Light's oscillating electric field drives a material's bound electrons like masses on springs (the Lorentz oscillator). Left: the driven electron. Near its natural frequency ω₀ it swings hard and lags the field. Right: two consequences of that one picture: absorption (red) peaks at resonance (those wavelengths are drained from the light, giving the material its color), and the refractive index n(ω) (blue) rises with frequency away from resonance (normal dispersion: n higher toward the blue) but dips sharply across it (anomalous dispersion). Interactive: pick a material, or choose Custom to drag the driving frequency and the damping yourself; press Play to watch the electron move. A "microwave oven mode" toggle jumps to water sitting on its dipolar (microwave) resonance, where absorption is strong, the reason a microwave oven heats water and food.
fig-atmospheric-scattering
Figure 2.1.19 (reproduced). Atmospheric scattering: why the sky is blue and the sunset orange. At midday (left) sunlight takes a short path through the atmosphere; air molecules scatter the short (blue) wavelengths in all directions, filling the sky with blue. At sunset (right) the light grazes a long path; its blue is scattered away before reaching the viewer, leaving the transmitted light red-orange. The same Rayleigh 1/λ⁴ scattering produces both effects, governed only by path length.
fig-xkcd-sky-color
Figure 2.1.20 (reproduced). xkcd #1145 "Sky Color", Randall Munroe, xkcd.com/1145 (CC BY-NC 2.5).
fig-rainbow-droplet
Figure 2.1.21 (reproduced). Why a drop makes a bow and a prism does not. Left: parallel sunlight enters a spherical water drop at different points, refracts, reflects once off the back, and exits bunched near the 42° rainbow ray, a caustic. A ray that only refracts through (no internal reflection) just passes on, turned but never concentrated. Middle: Descartes' construction: total deviation $D$ versus impact parameter $b$. The one-reflection curve has a minimum (≈138° → a bow at 42°); two reflections give the secondary (≈51°); the zero-reflection curve (two refractions only) is monotonic: no minimum, no caustic, no rainbow. Right: the same physics as an integral: the ray density as a function of deviation (summed over every impact parameter), which spikes exactly at the stationary deviation: that spike is the rainbow, and dispersion splits it into the three colored spikes shown. Above the caustic the sky is brighter inside the bow than outside it; below the minimum lies Alexander's dark band, where no rays arrive. Interactive: it is a water drop; drag the impact parameter, choose the number of internal reflections, and tick "zoom near the caustic" to re-range both the slider and the plot tightly around the bow. Dispersion is always on, so the colors separate near the minimum.
fig-rainbow-glass-sphere
Figure 2.1.22 (reproduced). A glass sphere as a stand-in for a raindrop. A bright white source refracts into a clear glass sphere, reflects off its back surface, and refracts out, throwing a small rainbow caustic onto the card, its colors fanned by dispersion. The same single-drop geometry, multiplied over millions of drops, is the rainbow in the sky. (Author's demo.)
fig-rainbow-glass-sphere-rays
Figure 2.1.23 (reproduced). Seeing the rays. Narrow laser beams (red and green) sent through the same glass sphere in a hazy room make the paths themselves visible: each beam refracts in at the front, reflects off the back surface, and refracts out; the colors bend by slightly different amounts (dispersion), the very split that fans a raindrop's bunched light into the rainbow. (Author's demo.)
fig-rainbow-loch-ness
Figure 2.1.24 (reproduced). A double rainbow over Loch Ness. The broad, bright arch is the primary bow (red on the outside, ~42°); look just outside it for the fainter secondary bow, with its colors reversed (~51°). Between the two the sky is visibly darker (Alexander's band) because almost no rainbow light emerges into the 42°–51° gap; note too how the sky inside the primary bow is brighter than outside the secondary. The single-drop geometry of the diagram above, written across a whole sky of raindrops. (Photo: Frédo, Loch Ness, Scotland.)
Figure 1. community Upload your own rainbow photo to share with other readers. Extra credit for a double rainbow or a full-circle one.
Video 2. Veritasium: "You're Probably Wrong About Rainbows." The 42° caustic, why the colors order as they do, and the fainter secondary bow: the same single-drop refract–reflect–refract geometry sketched in the sidebar above, shown with real optics and simulation. (web edition)

Scattering and absorption in media. The same physics that paints the sky operates at close range whenever light travels through a participating medium such as fog, haze, smoke, or water. Light is scattered out of its straight path and absorbed along the way, so distant objects lose contrast and take on the color of the medium (the bluish veil of haze, the green-blue cast underwater). When light scatters only once before reaching the camera the effect is mild; multiple scattering through thick fog washes the scene out entirely. Undoing this (dehazing and de-weathering) is a recurring computational-photography problem, and it is built on exactly the scattering model sketched here.

Viewpoint, lenses, and focus⧉

Choosing and checking autofocus⧉

optional

Use single-shot autofocus for a stationary subject when the camera and subject distance will remain fixed. Use continuous autofocus when distance changes, and choose a focus area that excludes likely distractions. Eye detection can select a useful target, but inspect which eye was selected and whether its detail is actually sharp. A detection box indicates a target, not a focus measurement.

Contrast-detection autofocus searches for a sharpness maximum. Phase-detection autofocus compares views through different parts of the pupil to estimate the direction and amount of defocus. On-sensor phase detection avoids a separate focus sensor, but it still needs usable image structure and a calibrated lens response. Repeating patterns, low contrast, obstructions and rapid motion can defeat either approach. Chapter 22.9, Autofocus explains the measurements; Chapter 22.8, Focus covers the mechanics.

Manual focus is useful when automation repeatedly chooses the wrong surface, or when a repeatable focus position matters more than tracking. Magnified live view is a direct check. Focus peaking highlights contrast and can also highlight noise or a textured surface that is not quite sharp enough. A focus limiter restricts the lens's search range and can prevent a long excursion toward an irrelevant foreground. For a focus pull in video, check whether framing changes with focus, a lens property called focus breathing.

fig-af-families
Figure 5.3.4 (reproduced). The three autofocus families. CDAF climbs the contrast/sharpness curve. It is accurate but must hunt, since one frame gives no direction. PDAF splits the lens into two sub-apertures; the phase shift between the two views gives direction and distance in one shot, with little or no hunting. It is a tiny stereo measurement. On-sensor PDAF / dual-pixel puts that split inside the imaging sensor: each photosite is divided into halves that see opposite sub-apertures, giving phase detection at (nearly) every pixel.
fig-pdaf-phase
Figure 5.3.5 (reproduced). Phase-detection geometry. The two sub-aperture views of a scene point coincide when the image is in focus; when the subject is too near, the two views separate one way; when too far, they separate the other way. The sign and magnitude of the separation tell the lens which way and roughly how far to move, so focus can often be reached in one step, with a final check when noise or lens response make the estimate uncertain.

A fence illustrates why choosing the focus target matters as much as choosing the autofocus mode. A broad area can lock onto the high-contrast wire in front of the subject. A smaller focus area, a suitable tracking target, or manual focus lets you specify which depth matters. Repetitive patterns and low contrast can make the choice uncertain even when the focus motor is fast. Check the intended feature rather than only the camera's confirmation symbol.

A focus limiter restricts the distance range the lens searches, when the lens provides one. For a distant bird, excluding nearby distances can prevent a long search through an irrelevant range. For a close subject, leaving that restriction engaged can prevent focus entirely. The limiter changes the search, not the depth of field or the lens's optical resolution.

Phase detection has a geometric interpretation: the two pupil regions see slightly displaced images when the subject is defocused. Comparing them can provide a direction in which to move focus, where a single contrast measurement merely reports how sharp the current image is. Older SLR implementations used a separate autofocus sensor fed through the mirror system. On-sensor implementations use selected masked pixels or split photodiodes to sample the pupil views at the imaging sensor. Dual-pixel measurements can also supply depth cues for computational defocus, within the limits of their small baseline.

Depth-from-defocus methods make a different measurement. Compare images acquired at different focus settings and use a calibrated model of how the lens blur changes to estimate the required focus adjustment. The model depends on the lens and capture conditions. This explains how useful focus information can be obtained without dedicated phase-detection pixels, and why calibration and a final sharpness check still matter.

Back-button focus is a control choice rather than a new focusing method: a separate button triggers focus while the shutter button triggers capture. It lets the photographer decide when a previous focus setting should be retained and when it should be updated. As with a focus limiter, its usefulness depends on understanding what the control leaves fixed.

Image stabilization⧉

optional

Camera shake and subject motion need different remedies. Optical stabilization moves a lens group; in-body stabilization moves the sensor. Either can reduce some camera-induced image motion during the exposure, within its correction range. Digital stabilization warps and crops recorded frames; alignment alone does not undo the blur already integrated within each frame.

A stabilized wall can look sharp behind a blurred person. Shorten time for the person or use a sufficiently brief flash when ambient light is weak enough. Advertised stabilization stops describe a particular test and success criterion: a claim of four to five stops means that, under that test, a shot that needed 1/100 s might succeed between about 1/6 s and 1/3 s. Verify a repeatable handholding time with your own focal length, stance and output size. For deliberate panning, use the supported panning mode or check whether correction fights the intended movement.

fig-stabilization
Figure 5.3.6 (reproduced). Three stabilization schemes. OIS: a floating lens element shifts to counter shake. IBIS: the sensor rides a gimballed stage and counter-moves, working with any lens. EIS / digital: a margin is cropped and each frame warped to cancel motion, with no moving parts, at the cost of resolution and field of view. In all three, a gyroscope senses the angular shake and drives the counter-motion. Digital stabilization cannot undo blur within a frame, and a moving subject stays blurred in all three.

Fourier⧉

MTF: a lens's frequency response⧉

optional

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

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

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

Aberrations and optical challenges⧉

Radial distortion⧉

in the book↗

What it is. Distortion is the odd one out among aberrations: it does not blur anything. Every point stays perfectly sharp; the magnification simply varies with how far the point is from the center of the frame, so points land at the wrong radius. When magnification falls toward the edge, straight lines bow outward, barrel distortion (think of a barrel's bulging sides), typical of wide-angle lenses. When magnification grows toward the edge, lines bow inward, pincushion distortion, typical of telephotos. Zooms often do both at different focal lengths.

What it looks like. Straight edges that should be straight, such as the horizon, a building, a door frame, or the sides of the frame itself, curve gently. The effect is strongest near the frame edges and zero at the center; a square grid is the cleanest way to see it.

Why. A Seidel term, but a peculiar one: because it merely relocates sharp points along the radius rather than spreading their energy, it is the single most software-correctable defect in optics. A measured radial warp, a per-lens map of true radius to imaged radius, straightens the lines almost perfectly, which is why nearly every camera and phone ships with built-in distortion correction in the image pipeline. (It is also why a fisheye's dramatic barrel is treated not as an aberration but as an intended projection; see Chapter 22.7, Special optics.) The correction itself is detailed in Chapter 22.2, Aberrations correction.

The standard parametric models. The radial remapping is captured, for both lens-profile correction and camera calibration, by a low-order polynomial in the radius. Writing $r_u$ for the undistorted radius and $r_d$ for the distorted radius (both measured from the distortion center), the Brown–Conrady model Brown 1966 (Brown–Conrady) expands the distorted radius forward as

$$ r_d \;=\; r_u\,\bigl(1 + k_1 r_u^2 + k_2 r_u^4 + k_3 r_u^6\bigr), $$

with optional tangential (decentring) terms $p_1, p_2$ for elements mounted slightly off-axis; $k_1<0$ gives barrel, $k_1>0$ pincushion. An alternative that inverts more cleanly, and that often captures even strong wide-angle distortion with a single parameter, is the division model (Fitzgibbon) Fitzgibbon 2001,

$$ r_u \;=\; \frac{r_d}{1 + \lambda_1 r_d^2 + \lambda_2 r_d^4 + \cdots}, $$

which is why it is popular in calibration pipelines. Either way the correction is a one-dimensional curve fit per lens; the mechanics live in Chapter 22.2, Aberrations correction.

fig-distortion-barrel-pincushion
Figure 22.1.10 (reproduced). Radial distortion on a square grid. Barrel (left): magnification rises toward the edge, so lines bow outward, the wide-angle signature. Pincushion (right): magnification falls toward the edge, so lines bow inward, the telephoto signature. Corrected (center): a measured radial warp restores straight lines. Unlike other aberrations, distortion moves no light energy: points stay sharp, just mis-placed, which is why software undoes it almost perfectly.

Vignetting⧉

in the book↗

What it is. The image gets darker toward the corners. Two distinct mechanisms share the name. First, a geometric effect in the simple rectilinear model: light reaching the corner of the frame arrives at a steep angle and is dimmed by a factor of $\cos^4\theta$ (the natural or $\cos^4$ falloff introduced in FUNDAMENTALS, from the tilt of the pupil, the longer path, and the foreshortened aperture). Second, optical vignetting (sometimes mechanical vignetting): off-axis, the lens barrel and the front and rear elements partially block the aperture, clipping the bundle of light that would otherwise reach the corner.

What it looks like. A gradual darkening from a bright center to dim corners, strongest wide open for the optical component and largely independent of aperture for the $\cos^4$ component. Optical vignetting also reshapes the out-of-focus highlights near the edges into cat's-eye or lemon shapes (the clipped pupil), a bokeh effect developed in Chapter 23.1, Bokeh, focus stacking, and depth-of-field control. Stopping down shrinks the bundle enough to clear the obstructions, so corner brightness (and round bokeh) return.

Why. The $\cos^4$ law assumes the simple pupil and projection model; pupil distortion and lens design can change the falloff. The optical part is the finite size of the barrel and elements clipping the entrance pupil off-axis. Both produce a smooth radial brightness map, which is exactly what makes vignetting easy to undo: a measured radial gain map in the image pipeline lifts the corners back to match the center (at some cost in corner noise). That correction, together with the distinction from sensor- and microlens-induced falloff, is in Chapter 22.2, Aberrations correction.

fig-cos4-vignetting
Figure 22.1.11 (reproduced). Vignetting. Natural ($\cos^4$) falloff (left): even a perfect lens dims the corners by $\cos^4\theta$ because off-axis rays arrive tilted, travel farther, and see a foreshortened aperture. Optical vignetting (center): off-axis, the barrel and front/rear elements clip the light bundle, darkening corners further and squeezing edge highlights into cat's-eye shapes; it eases on stopping down. Corrected (right): a measured radial gain map restores even brightness across the frame.
fig-vignetting
Figure 22.1.12 (reproduced). Vignetting, ray-traced on the usual Cooke triplet (interactive). A bundle of parallel rays enters at a field angle and must clear every element rim and the aperture stop; on axis the whole bundle passes, but off axis the oblique cone is clipped fore-and-aft into a shrinking cat's-eye, so fewer rays reach the corner: optical (occlusion) vignetting. On top of that sits the aperture-independent $\cos^4\theta$ law: an off-axis image patch is farther from the exit pupil and sees it foreshortened and tilted, and is lit by rays arriving obliquely: three cosines plus one more for the inverse-square falloff. Set the aperture and watch the occlusion melt as you stop down (the clipped marginal rays are gone anyway), leaving only $\cos^4$, which is why vignetting cleans up a couple of stops down. Choose which falloff the 2-D frame shows: none, $\cos^4$ only, or $\cos^4$ combined with occlusion. The illumination-versus-field-angle plot overlays all three so the two mechanisms can be read apart. Interactive: pick the f-number and field angle to see which rays the barrel and stop clip, with the relative-illumination curve and a 2-D frame for no vignetting, $\cos^4$ only, or $\cos^4$ + occlusion.

Flare and coating⧉

in the book↗

What it is. Aberrations are wanted rays landing in the wrong place; flare is unwanted light reaching the sensor at all. At every air–glass surface a few percent of the light reflects instead of transmitting: about 4% per uncoated surface, from the Fresnel reflectance $R = \big((n_1-n_2)/(n_1+n_2)\big)^2$. In a lens with a dozen surfaces those stray reflections bounce around and arrive as junk light. A ray that reflects twice can refocus into a discrete, often aperture-shaped bright blob, called a ghost, typically strung along a line from a strong light source through the frame center. Many faint scatters and reflections sum into veiling glare, a low-frequency wash that lifts the blacks and crushes contrast.

What it looks like. Shooting into the sun or with a bright source just outside the frame: a chain of colored polygonal ghosts marching across the picture, streaks and stars, and an overall milky loss of contrast in the shadows. The more elements a lens has, the worse it would be. $N$ surfaces give $O(N^2)$ pairs of surfaces that can inter-reflect, one cost of the many-element designs the rest of the part relies on.

Why. Fresnel reflection at each interface. The thing that made many-element lenses practical is the anti-reflection coating: a thin transparent film with quarter-wave optical thickness at a design wavelength, $n_{\mathrm{film}}t=\lambda_0/4$ at normal incidence, whose two surface reflections interfere destructively and nearly cancel the reflection over a band, the faint colored sheen on a modern lens. Coatings drop per-surface reflection from ~4% toward a few tenths of a percent. The numbers compound. Through twelve uncoated surfaces the image keeps $0.96^{12}\approx 61\%$ of the light; at 0.5% per surface it keeps $0.995^{12}\approx 94\%$. A ghost needs two reflections, so its strength goes as the square of the reflectance: $0.04^2=1.6\times10^{-3}$ of the source uncoated against $0.005^2=2.5\times10^{-5}$ coated, 64 times weaker for each pair of surfaces. Alongside coatings, lens hoods and internal baffles keep stray off-axis light from entering in the first place. This chapter only names flare as one of the optical challenges; the physics of thin-film coatings, hoods, baffles, and computational deflare is the subject of Chapter 22.10, Glare suppression.

fig-lens-flare-ghosting
Figure 22.1.13 (reproduced). Flare and ghosting. A bright source sends most of its light to the sharp image, but at each air–glass surface ~4% reflects (Fresnel). A ray that reflects twice refocuses as a ghost, a discrete, aperture-shaped blob usually strung along the line from the source through the frame center, while countless weak scatters sum into a contrast-killing veiling glare. Anti-reflection coatings cut the per-surface reflection toward a few tenths of a percent; the cures are detailed in Chapter 22.10, Glare suppression.

You can watch the ghosts form by tracing a single ray through a real lens (Figure 22.1.14).

fig-lens-flare
Figure 22.1.14 (reproduced). Flare, traced (interactive). A full recursive ray trace of the Cooke triplet from the optics ray-tracer: at every air–glass surface the ray both refracts (transmits) and reflects (Fresnel, ~4% uncoated, angle-dependent), and every branch is followed until it leaves the lens or falls below a brightness floor. Set where the ray meets the first element and its direction; the sensor at right marks every place light lands. The bright spot is the real image (the all-refraction path); the orange spots are ghosts from even numbers of internal reflections, strung along the axis toward the source. Raise the reflection limit to see higher-order ghosts, and toggle an anti-reflection coating (0.3% per surface) to watch them nearly vanish, the whole point of coating a lens. Interactive: aim one ray into the triplet and follow its reflected and refracted branches to every landing point on the sensor, with and without an AR coating.

Seen quantitatively, the coating's quarter-wave trick is the same thin-film interference that colors a soap bubble (Chapter 2.1, Light and optics, Figure 2.1.33), now turned to the opposite use: instead of reinforcing a color it is tuned to cancel the reflection. Two interactive views make the mechanism concrete. The first plots the reflectance of bare, single-coated, and double-coated glass across the whole visible band and across the angle of incidence at once (Figure 22.1.15): a single quarter-wave film of magnesium fluoride cuts the ~4% bare-glass reflection to about 1% near its design wavelength, and a matched double layer (a low index over a higher one) drives it almost to zero across a band, while both climb back toward grazing incidence. The second rebuilds the soap-bubble wave picture as a coating on glass (Figure 22.1.16): five waves strike the surface and each reflected wave shrinks as you set the film thicknesses, nearly vanishing where the film's two surface reflections cancel, with the color of the leftover reflection shown as a swatch, the faint sheen of a coated lens.

fig-coating-reflectance
Figure 22.1.15 (reproduced). Anti-reflection coatings, over wavelength and angle, interactive. Bare crown glass reflects about 4% per face; a single quarter-wave film (magnesium fluoride, $n = 1.38$) makes its two surface reflections interfere destructively and cuts that to ~1% near the design wavelength; a matched double layer (low index over high) cancels it almost completely across the visible band. Choose the coating and drive the angle and wavelength. An animated wave picture shows, for three wavelengths at once, each interface's individual reflection (faint) merging into their interference sum (bold), adding up for bare glass, largely canceling for a single coating, and nearly vanishing for the matched double coating, and three plots give the exact thin-film reflectance (characteristic-matrix method, unpolarized): versus wavelength at the chosen angle, versus angle at the chosen wavelength (reflection always climbs toward grazing), and a 2-D map over both with a crosshair at the current setting. Interactive: pick no / single / double coating and sweep angle and wavelength; read the reflectance as a wave amplitude, as curves versus wavelength and versus angle, and as a 2-D map over both.
fig-coating-thin-film
Figure 22.1.16 (reproduced). An anti-reflection coating, wave by wave, interactive. The thin-film picture of the soap bubble, rebuilt as a coating on glass ($n_s = 1.52$). Five waves across the visible band strike the surface at the chosen angle; each reflected wave is shorter than its incident one by the reflectance. Bare glass reflects ~4% at every wave; add a single quarter-wave film or a matched double layer and set the two thicknesses, and the reflected waves shrink toward nothing where the film's surface reflections cancel. Each reflected amplitude is $\\sqrt{R(\\lambda)}$ from the exact characteristic-matrix result; a plot gives the reflected light across the whole band (with bare glass as a dashed reference), and a swatch shows the color of the leftover reflection. Interactive: choose no / single / double coating, set the outer and inner film thicknesses, and watch five reflected waves shrink while the reflected-light-per-wavelength plot dips, reaching near zero for a matched double layer.

Modern lenses push past the quarter-wave film, which has two limits: its ideal single-layer index is $\sqrt{n_\text{glass}}\approx 1.23$, below the index of most conventional dense coating materials, and a fixed film cancels only near one wavelength and one angle, so reflections return at the steep angles where ghosts are worst. Two families of nano-coating get around both. The first builds a film riddled with nanometer voids or hollow silica spheres, so its effective index is a blend of glass and air, low enough (around 1.1) to be the matching layer no bulk material provides: Nikon's Nano Crystal Coat uses gaps between nanoparticles, and Canon's Air Sphere Coating incorporates air in a silica-based film. Sony's Nano AR is another nanostructured anti-reflection technology; the trade names do not imply identical material or fabrication recipes. The second gives up the flat interface: a dense array of subwavelength wedges or cones a few hundred nanometers tall makes the index climb gradually from air to glass, so there is almost no boundary to reflect from, over a wide band and a wide range of angles. This is the moth-eye structure of Canon's SWC, copied from the moth's cornea, with performance depending on wavelength, angle, and the particular surface design. Both are subwavelength structures, which they share with metalenses and metasurfaces, but they only grade or interfere the index and impose no engineered phase profile: they are effective-medium anti-reflection, not the wavefront-shaping of metaoptics. Making them is the hard part: fabrication routes include grown nanostructures, nanoimprinting, and nanoparticle or porous films. Their uniformity and durability on curved optics are part of the design problem; these are families of processes, not a single recipe shared by all brands. Their details, and computational deflare, are in Chapter 22.10, Glare suppression.


With the bestiary in hand, the rest of the part divides cleanly. The defects you have just met are met in turn by more glass (the compound designs of Chapter 22.5, A short bestiary of classic designs, each element added to cancel a specific term) found by the optimization of Chapter 22.4, Lens optimization, and finally by computation, which calibrates and corrects whatever the glass leaves behind. The analytic heart, where each aberration's cause and cure is developed in full (the Seidel sum, the achromat condition, lens-profile correction, and deconvolution by the measured PSF), is Chapter 22.2, Aberrations correction. Keep this catalog beside it: it is the list of diseases that the rest of the part exists to treat.

Aberrations correction⧉

Computational correction⧉

optional

Everything above fights the aberration in the optics. The computational-photography move is to let the optics get the image only close and finish the job in the image-signal processor (ISP), shifting the design's operating point on the cost-versus-quality front (cross-ref Chapter 22.4, Lens optimization). Two tools do the bulk of it, and they map cleanly onto the two kinds of aberration: geometric (a sharp image in the wrong place) versus blur (light spread out of place).

The first tool is lens-profile correction, and it handles all three of these profile-correctable effects. For each lens, and for each combination of focal length, aperture, and focus distance, the manufacturer or a community database measures a profile: a table of how that lens distorts, vignettes, and color-fringes. Then the ISP simply plays the profile in reverse on every frame. Geometric distortion is undone by a radial warp, resampling each pixel along a corrective function of its distance from center, $r' = r\,(1 + k_1 r^2 + k_2 r^4 + \cdots)$. The direction of this map must be specified: a forward Brown–Conrady polynomial maps undistorted coordinates to distorted source coordinates, which is exactly what output-to-input resampling needs. Its mathematical inverse is not generally another polynomial with negated coefficients. Resampling restores geometry but can change sharpness, crop the image, and stretch corner samples. Vignetting is undone by a radial gain map, brightening the corners back to the center's level. The same map corrects both the lens's optical vignetting and the FUNDAMENTALS $\cos^4$ falloff in one pass (cross-ref the natural-illumination falloff there). Lateral CA is undone by rescaling each color channel radially about the center by the tiny per-channel factor the profile records, collapsing the red-to-blue fringe back to a single edge. All three are widely used, particularly in camera-generated images, though raw converters and lens combinations differ in which profiles they apply. Phone lenses in particular are designed expecting this correction, deliberately leaving in heavy barrel distortion (it lets the optics be smaller and faster) on the understanding that software will straighten it. This is routine optics-plus-computation.

fig-lens-profile-correction
Figure 22.2.5 (reproduced). Lens-profile correction in the ISP. A pipeline diagram. Left, the raw frame off the sensor: barrel-distorted, dark in the corners (vignetting), with colored fringes toward the edges (lateral CA). A measured lens profile, indexed by lens, focal length, and aperture, supplies three correction maps: a radial geometric warp (undo distortion), a radial gain map (undo vignetting, including the $\cos^4$ falloff), and a per-channel radial rescale (undo lateral CA). Right, the corrected output: straight lines, even brightness, clean edges. A note flags that this fixes only the geometric defects (distortion, vignetting, lateral color) and not the blur-type ones.

The second tool reaches the blur-type defects, and it is where this chapter rejoins the deblurring machinery from the single-image part. An aberrated lens does not just displace points. For spherical aberration, coma, astigmatism, and axial CA, it genuinely spreads each point into a small blob, the lens's point-spread function (PSF). The forward model is the one convolution we keep returning to: within a small region with approximately constant PSF, the recorded image is the ideal scene convolved with that PSF, plus noise,

$$y=x*k+n.$$

Here $x$ is the ideal image, $k$ the local PSF, $n$ the noise, and $y$ the observation. Across the full frame, use a space-varying operator $y(p)=\sum_q k(p,q)x(q)+n(p)$ rather than one convolution.

If we know the PSF, we can try to invert that convolution, by deconvolution, and recover the sharp scene. And for a known lens we can know the PSF, by measuring it (shoot a point source or a calibration target through the lens). This difference from blind motion deblurring matters: here the kernel is calibrated, not guessed, so the inversion is a non-blind deconvolution, the easier problem. It uses exactly the regularized-inverse toolbox from Chapter 6.3, Linearity, Fourier, aliasing and deblurring, the Wiener filter prototype

$$\hat X = \frac{\overline{K}\,Y}{|K|^2 + \mathrm{SNR}^{-1}},$$

where $X,Y,K$ are Fourier transforms and $\mathrm{SNR}^{-1}=S_n/S_x$ is the ratio of noise and signal power spectra at that frequency. This is not the local amplitude SNR used in the noise chapter. The filter at each frequency divides the blur back out where there is signal worth recovering and suppresses frequencies where the lens left too little signal relative to noise. The one twist particular to lenses is that the PSF is spatially varying (it is tight in the center and grows comatic and stretched toward the corners), so the deconvolution must use a different kernel per region of the frame, a calibrated map of PSFs rather than one global blur. Kee et al. Kee, Paris et al. 2011 (spatially-varying optical blur) do exactly this end to end: calibrate a lens's spatially-varying PSF across the field (and across zoom/aperture) and remove the resulting optical blur by per-region non-blind deconvolution.

fig-psf-deconvolution
Figure 22.2.6 (reproduced). Deconvolution by the measured PSF. Top, the measured PSF of a lens at one field position: a small asymmetric blob (comatic toward the corner), captured by imaging a point source. Middle, the recorded image: scene $*$ PSF, softened by that blur. Bottom, the result of non-blind deconvolution by the known kernel (a Wiener / regularized inverse), with detail restored. An inset shows the same correction applied with different PSFs at center vs. corner (the spatially-varying case), and a second inset shows the failure mode: where the PSF's spectrum dipped to zero, the inversion only amplifies noise, recovering nothing.

The limits are the same as in any deblurring problem. Deconvolution amplifies noise at exactly the frequencies the lens attenuated most, its modulation transfer function (MTF) dips toward zero there, so it can sharpen what was merely attenuated but cannot recover what was destroyed: information the optics drove below the noise floor is gone, and pushing the inverse harder there only manufactures grain and ringing. The spatial variation adds bookkeeping (a grid of kernels, blended across the frame). And axial CA, being a differently-defocused-per-color blur, is partially correctable this way but never as cleanly as lateral CA's one-line warp.

All of this fights the blur the lens accidentally made. A forward-looking extension of this chapter, and a bridge to the Advanced part, is to engineer the PSF rather than just correct it: design the lens (or a coded aperture, or a phase mask) so that its blur is deliberately chosen to invert cleanly, with better-conditioned transfer over the intended recovery band, and even to encode depth in its shape. That is wavefront coding and coded-aperture imaging (Dowski and Cathey, 1995), and the end-to-end / differentiable-optics idea of optimizing the lens and the reconstruction algorithm together, which this part has been building toward. In that view, aberrations become signals to be designed.

Radial distortion correction⧉

in the book↗

Of all the defects in the catalog, radial distortion is the one that surrenders most completely to software, and it gets its own treatment here because it is both the most visible and the most cleanly correctable. Unlike blur, ideal geometric distortion changes point locations without spreading each point: every point stays perfectly sharp, the lens has merely mis-placed it radially, bending world-straight lines into gentle curves. Restoring them is therefore not a deconvolution (with all of deconvolution's noise-amplifying limits) but a remapping followed by interpolation, with sampling and boundary costs. It is so reliable that modern designs lean on it: a phone or compact wide-angle lens is routinely allowed to leave heavy barrel distortion in the raw frame (which lets the optics be smaller, faster, and cheaper) on the understanding that the image-signal processor will straighten it on every shot.

The symptom is bowed lines. A real lens images world-straight lines as gentle curves. In barrel distortion the lines bow outward and the frame seems to fatten (magnification falls with radius), the signature of wide-angle lenses; in pincushion distortion they bow inward as magnification rises with radius, typical of telephoto; a blend of the two is mustache distortion. The radial model is symmetric about a fitted distortion center, often close to the principal point and worst at the edges, and its extreme case is the fisheye, where the bending is so strong it is no longer a defect to remove but the intended projection.

The model is a per-radius remap. Because the effect is radially symmetric, the correction is a one-dimensional function of radius $r$ (the distance from the optical center) applied along each ray: points move only in or out, never sideways. The two parametric forms are exactly the ones introduced in Chapter 22.1, Aberrations and optical challenges, used here in reverse. The polynomial (Brown–Conrady) model writes the distorted radius forward as

$$ r_d = r_u\,\big(1 + k_1 r_u^2 + k_2 r_u^4 + \dots\big), $$

with $k_1<0$ for barrel and $k_1>0$ for pincushion; mapping a measured distorted point back to an undistorted point requires inversion. Rendering a corrected image usually needs the displayed forward map instead: for each undistorted output location, evaluate its distorted source location. One or two terms suffice for most lenses. The division (Fitzgibbon) model uses a rational form,

$$ r_u = \frac{r_d}{1 + \lambda_1 r_d^2 + \dots}, $$

which captures strong wide-angle and fisheye distortion with fewer parameters and inverts more cleanly, which is why it is favored for calibration.

Where the parameters come from. Two routes. The first is a lens profile: a precomputed table of coefficients per (lens, focal length, aperture), shipped by Lightroom / Adobe Camera Raw, PTLens, or DxO and looked up automatically from the EXIF tags that name the lens; this is the very profile the lens-profile-correction pass above already plays back to undo vignetting and lateral CA, so distortion comes off in the same step. The second is to estimate the coefficients from the image itself by plumb-line calibration: find features that ought to be straight (a building edge, a horizon) and choose the $k_i$ or $\lambda$ that make the imaged lines straight, minimizing their residual curvature.

Applying it is an inverse warp. Once the radial map is known, it is applied by the same engine as every geometric resampling operation, inverse-warp and resample: loop over output pixels, push each back through the radial map to its source radius, and resample the input (the warping machinery developed in Chapter 11.1, Warping in the motion-and-video part, which now points back here for this lens correction). The stretched and compressed edge regions carry the usual prefilter-before-downsample care, and the corners that read past the frame are handled by the boundary policy or simply cropped. The correction can straighten lines accurately, but stretching cannot create the additional samples a corner would have received from an optically rectilinear lens. Use a suitable interpolant and account for the output crop.

fig-radial-distortion-correction
Figure 22.2.7 (reproduced). Radial distortion correction, the cleanest geometric cure. A ruled grid shown three ways. Left: the grid through a lens with barrel distortion ($k_1<0$), straight lines bowed outward, the frame fattened, the edges magnified less. Middle: after the per-radius remap (an inverse warp + resample) the grid is straight again. Right: pincushion distortion ($k_1>0$) for contrast, the same lines bowed inward. One line is drawn in accent so the bow and its straightening read at a glance. Because radial distortion is radially symmetric and moves no light energy (points stay sharp, only mis-placed) the cure is a clean one-dimensional function of radius, $r_d = r_u(1+k_1 r_u^2+\dots)$, applied by the same inverse-warp engine as every other geometric correction, with no loss of sharpness.

Aberration data in the DNG, and the limits of per-copy correction⧉

optional

The profile a raw converter plays back need not come from a separate database; increasingly it rides inside the file. A DNG can carry lens corrections as opcodes, small typed operations the standard defines and stages along the demosaic pipeline (the OpcodeList1/2/3 fields). The geometric ones are exactly the corrections above: WarpRectilinear encodes the distortion and lateral-chromatic-aberration polynomials as per-channel radial coefficients, FixVignetteRadial carries the vignetting gain, and WarpFisheye handles the fisheye map; beside them sit FixBadPixelsConstant/List for dead and hot pixels (the subject of Chapter 8.9, Dead pixels) and per-pixel gain maps. A camera or raw converter can write these opcodes when it has an appropriate calibration. Their presence, version, optional/required flags, and reader support determine which corrections travel with a particular file; not every DNG includes a complete lens profile. The DNG is self-describing: the correction travels with the pixels.

The catch is that a supplied correction may represent the lens model rather than the copy in your hand; the format itself does not forbid per-unit calibration, and real lenses do not leave the factory identical. A purely radial profile assumes rotational symmetry; more general calibration can include a shifted center, tangential terms, or spatial gain maps, but manufacturing tolerances break that assumption. Decentering, an element tilted or shifted by microns, makes the blur and even the distortion asymmetric, worse on one side of the frame than the other, which no centered radial map can remove. Sample variation means two copies of the same lens distort and vignette by slightly different amounts, and the profile splits the difference. And the errors drift with focus distance and, on a zoom, with focal length, so a profile indexed only by the nominal settings is always a little off. Lens-profile correction is therefore excellent at the designed defect and merely approximate for your lens: it straightens the nominal barrel but can leave a faint residual mustache, evens the nominal vignette but not a decentered one. Closing that last gap needs a per-copy calibration, which a few high-end workflows and cameras actually perform, measuring the individual lens rather than trusting the model average.

Measuring lens quality⧉

in the book↗

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

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

The modulation transfer function (MTF)⧉

in the book↗

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Measuring MTF in practice⧉

optional

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

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

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

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

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

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

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

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

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

Spot diagrams and the PSF⧉

optional

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

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

MTF through focus and depth of focus⧉

optional

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

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

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

Field-dependent MTF: sagittal vs tangential⧉

optional

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

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

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

Color, geometry, and illumination measurements⧉

optional

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

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

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

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

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

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

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

Scalar quality summaries⧉

optional

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

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

Lens optimization⧉

in the book↗

In the FUNDAMENTALS part the thin lens did something miraculous: every ray leaving a scene point and passing through the lens reconverged to a single image point. That was a convenient lie: the paraxial linearization, $\sin\theta\approx\theta$, one wavelength, zero thickness. The opening aberrations chapters explained the limitations: keep the cubic term of Snell's law, let the index depend on color, give the glass real thickness, and a single element can no longer bring all the rays from all the points at all the colors to where they belong. The fix was to add elements, and adding elements added knobs (radii, glasses, spacings) that let the designer trade one defect against another.

This chapter is about turning those knobs. This chapter belongs here because choosing the lens parameters is an optimization problem of the same general form as the inverse problems elsewhere in the book. There is no formula for the perfect lens past first order. So you search numerically rather than solving in closed form. You write down a single number that measures how badly a candidate lens performs, summed over everything it has to do at once, and you let an optimizer push the knobs until that number is as small as you can get it. Lens design applies the book's optimization theme to optics.

The high-level idea: design as optimization⧉

in the book↗

Start with why a general photographic lens requires numerical design. The paraxial equations of the thin lens are linear: power adds, the lensmaker's equation is closed-form, and you can solve for the focal length you want in one line. But the moment you keep the next term of $\sin\theta \approx \theta - \theta^3/6$, the equations become nonlinear. Nonlinearity alone does not exclude a closed-form solution, and special exact constructions exist, but there is no general closed-form prescription that places every ray from every field point at every wavelength through every part of the aperture onto its ideal spot. The conditions overdetermine the lens: you have more things you want to be true than you have surfaces to make them true with. Past first order, design becomes a search through a space of candidate lenses rather than a derivation of the one right answer.

So we set the problem up the way the book sets up every optimization. We need three things: the unknowns we are free to vary, an objective number to minimize, and (next section) a forward model that turns unknowns into that number.

The parameters are the unknowns. A lens is described by a list of numbers, and almost every one of them is a free variable the designer can move:

Collect all of these into a single parameter vector $\mathbf{p}$. A modest lens has a dozen or two entries; a complex zoom has many more. The design space is whatever $\mathbf{p}$ can range over.

The objective is the merit function. Now the single number. We want a candidate lens to be judged by one scalar so that "better" and "worse" are unambiguous and an optimizer has something to descend. That scalar is called the merit function $\Phi(\mathbf{p})$, and its job is to sum up residual aberration over every condition the lens must satisfy at once. Concretely, $\Phi$ is a weighted sum of squared ray errors,

$$ \Phi(\mathbf{p}) \;=\; \sum_{\text{fields}}\;\sum_{\lambda}\;\sum_{\text{pupil rays } i} w_i \,\bigl\lVert (x_i, y_i) - (\bar x, \bar y)\bigr\rVert^2 \;+\; (\text{constraint penalties}), $$

where $(x_i, y_i)$ is where ray $i$ actually lands on the image plane, $(\bar x, \bar y)$ is the selected reference location. A centroid target measures spot spread; an ideal image-position target also penalizes displacement, and $w_i$ is a weight letting the designer say which conditions matter more. The three nested sums are the whole point: the lens is scored across a grid of field angles (image center out to the corner), across a set of wavelengths (classically the C, d, and F spectral lines, corresponding roughly to red, yellow-green, and blue, so color errors can be counted, provided the wavelength spots share a common image-position reference when lateral color matters), and across a sampling of aperture/pupil zones (rays through the center of the aperture and rays through its edge). A lens that is razor-sharp on-axis in green but smeared in the corners and fringed in blue scores badly, exactly as it should.

Two things about the form of $\Phi$ matter, because they are precisely the book's recurring structure. First, it is a sum of squared residuals, that is, a least-squares objective, the same shape as the regression and linear-inverse problems of Part 6, Linear methods and Fourier analysis; here the "residual" is a ray missing its target instead of a prediction missing a data point. Second, the trailing constraint penalties play the role of regularizers. A lens that minimized blur alone might come out the wrong focal length, three meters long, or with an element so thin its edge is negative (physically impossible to grind). So $\Phi$ carries hard constraints and penalties (hit the target focal length $f$, keep total length under a budget, keep every edge thickness positive, respect vignetting limits) that pull the solution toward something manufacturable and useful, not merely sharp. Data-fit plus regularization, the same bargain as everywhere else in the book.

The continuous view of the merit function. It helps to picture what $\Phi$ is really approximating. Imagine integrating the blur the lens produces over all the conditions it must satisfy simultaneously (every field point in the image, every wavelength in the band, every position across the pupil), one giant integral of badness over the whole space of imaging conditions:

$$ \Phi \;\approx\; \iiint w\,(\text{blur})^2 \; d(\text{field})\,d\lambda\,d(\text{pupil}). $$

You cannot evaluate that integral in closed form, so you sample it: a finite grid of fields, a few wavelengths, a finite set of pupil rays. The discrete merit function above is that integral, sampled, exactly the way Monte Carlo or quadrature stands in for an integral you cannot do by hand. Reducing the sampled sum improves the sampled conditions. Validate denser and independent samples to detect an optimizer exploiting gaps between fields, wavelengths, or pupil rays. This "big loss integral, sampled to a finite sum" is the same mental picture as a training loss averaged over a dataset, and it is the bridge that makes lens design feel native to the rest of the book.

The forward model: ray-tracing and spot diagrams⧉

optional

The merit function asks "where does each ray actually land?" Answering that, for a given candidate $\mathbf{p}$, is the forward model, and here it is exact ray-tracing, no paraxial shortcut.

The procedure is mechanical and is exactly what the FUNDAMENTALS part set up, run to completion. Pick a field point (say, a star at $5°$ off-axis). Launch many rays from it, fanned out to pass through a grid of points across the aperture: center, edge, top, bottom. Follow each ray surface by surface through the lens, and at every air–glass interface apply the full Snell's law,

$$ n_1 \sin\theta_1 = n_2 \sin\theta_2, $$

with the true angles $\theta_1, \theta_2$ between the ray and the surface normal, the genuine non-linear law, not the linearized $n_1\theta_1 = n_2\theta_2$ the thin lens used. Bend the ray, propagate it to the next surface, refract again, and so on until it reaches the image plane. Record where it lands. Do this for every ray in the fan, for every field point, and for every wavelength (the index $n$ feeds in the wavelength, so different colors bend differently and land differently). That landing-point bookkeeping is the entire evaluation of one candidate lens.

Spot diagrams. Now plot, for one field point and one color, the landing points of all those rays on the image plane. That scatter of dots is a spot diagram (Figure 22.4.1). It is the most direct picture of how good the lens is at that condition: a tight cluster means every ray from that point converges to nearly the same place, so the image is sharp, while a smeared blob means the rays scatter and the image is aberrated. The shape of the blob even diagnoses which aberration dominates: a round symmetric haze is spherical aberration, a one-sided comet is coma, a cross or ellipse is astigmatism (the Aberrations chapter reads these signatures in detail). And because you trace each color separately, different wavelengths produce different clusters, displaced or differently sized: that displacement is chromatic aberration, visible at a glance.

A spot diagram is a ray-sampled estimate of the lens's point-spread function. The point-spread function (PSF) is what the image of an ideal point source looks like after the optics smear it; tracing a fan of rays and seeing where they pile up is precisely a geometric estimate of that smear. So the thing the merit function measures, the size of these spots, is the geometric stand-in for image sharpness, and a useful approximation when geometric aberrations dominate. Near the diffraction limit, wave propagation is needed for the PSF used in deconvolution.

The optimizer's job, then, is to shrink these spots across all fields and colors at once. You cannot just make the on-axis green spot tiny; the merit function is watching the corner spots and the blue spots too, and squeezing one often bulges another. The design loop (Figure 22.4.2) is the obvious one: take the current parameters, ray-trace the whole grid of fields and colors and pupil zones, collect every landing error into the merit value $\Phi$, let the optimizer propose a step in $\mathbf{p}$ that should lower $\Phi$, and repeat until it stops improving. Designers also use root-mean-square (RMS) spot radius plotted against field angle (Figure 22.4.3): a curve showing how the average spot size grows from center to corner, which immediately reveals where in the frame the design was forced to give up quality, almost always the corners, where the constraints fight hardest.

fig-spot-diagram
Figure 22.4.1 (reproduced). Spot diagrams: the merit function's raw material. For a single field point, a fan of rays is traced through the lens and their intersections with the image plane are plotted as a scatter of dots, the geometric point-spread function. A tight cluster (left) is a well-corrected design; a smeared blob (right) is aberrated, and the blob's shape names the aberration (round haze = spherical, comet = coma, ellipse = astigmatism). Tracing each wavelength separately gives displaced or resized clusters per color, and that displacement is chromatic aberration. The optimizer shrinks these spots across all field points and colors at once; the panels show one field point before and after optimization.
fig-merit-function-loop
Figure 22.4.2 (reproduced). The lens-design optimization loop. Start from a candidate parameter vector (surface curvatures, glasses, thicknesses, air gaps, asphere coefficients). Ray-trace the design across a grid of field angles, a set of wavelengths, and a sampling of pupil zones, recording where every ray lands. Collapse all the landing errors, plus the constraint penalties (focal length, length, edge thickness), into a single merit value. The optimizer proposes a parameter step that should lower it; loop until the merit stops improving. This is the book's forward-model-plus-loss-plus-iterative-optimizer pattern, applied to glass.
fig-rms-spot-vs-field
Figure 22.4.3 (reproduced). RMS spot radius across the field. The root-mean-square radius of the spot diagram is plotted against field angle, from image center (left) to corner (right), for a few wavelengths. The curve typically rises toward the edge of the frame, showing where the design was forced to compromise: corners cost more than centers, because off-axis aberrations and field curvature pile up there. Designers read this curve to see whether the quality is balanced across the frame or dumped into the corners.
fig-lens-optimizer-demo
Figure 22.4.4 (reproduced). Interactive: a lens-design optimizer, in 3-D with a 2-D slice. Stack up to five glass elements (set each one's index of refraction, its two surface radii R₁ (front) and R₂ (back) independently, and its position and dispersion) and the demo ray-traces the design four ways at once: an orbitable 3-D scene where a cone of rays arrives at the lens and converges on the sensor (surfaces of revolution, vector Snell's law, no paraxial shortcut); a 2-D meridional slice of those same rays; the spot diagrams at the center and edge of the field; and a close-up of the rays reaching the sensor, where the focus shift across the spectrum (seven wavelengths, violet to red) reveals chromatic aberration. Hit Run optimizer and it runs damped least squares (Levenberg–Marquardt) with basin-hopping restarts (see the note below) to minimize the RMS spot over three field points and a spread of wavelengths at once, varying every curvature, air gap, and thickness, while a geometry penalty keeps the elements from interpenetrating or crossing the sensor; watch the merit fall and the spots tighten. The object sits far away (a near-collimated bundle, as a camera sees the world) and the sensor is a fixed image plane, so the lens is held to a normal focal length and can't cheat aberration down by stretching to a long conjugate. A weight slider lets you tell the optimizer to favor the center or the edge of the field, and an aperture slider sets how fast the lens is: open it up and spherical aberration (which grows with aperture³) explodes; stop it down and the same design snaps sharp. A focal-length dial (in 35 mm-equivalent terms) sets the field of view the design has to cover. Try each starting design: a singlet stays soft (one element cannot be corrected); an achromatic doublet snaps sharp on-axis but smears at the edge into the comet-shaped coma the 2-D slice can only hint at; the Cooke triplet brings the whole field under control: a crisp center (tens of microns wide open, single-digit stopped down) softening gracefully toward the corners, the classic sharp-center, soft-corner signature of a three-element lens. The four-element Tessar adds a cemented group and more freedom, but, like real designs, it is a harder, more local optimization, so a single run does not always beat the triplet, which is precisely why the professional tools reach for the global search of the next sections. A replay slider scrubs back through the optimization, reset optimization undoes the run while keeping your configuration, and the spot-diagram and close-up scales hold fixed during a run so a shrinking spot really shrinks instead of re-zooming. The demo makes the chapter's main tradeoffs interactive: forward model, merit function, the center-versus-edge trade, and the local-minimum trap.
Margin note: what the demo's optimizer actually does (and the tricks it needs)

The interactive optimizer above is not a canned animation; it runs the real machinery of this section, and getting it to converge to good lenses needed exactly the tricks the professional packages use, which recur whenever a least-squares problem is non-linear and non-convex.

  • Damped least squares (Levenberg–Marquardt). The merit is a sum of squared ray misses, so each step builds the Jacobian of every ray's transverse error with respect to every variable (here by finite differences: perturb a parameter, re-trace, see how the spots move), then solves the damped normal equations $(\mathbf J^\top\mathbf J + \lambda\,\mathrm{diag})\,\boldsymbol\delta = -\mathbf J^\top\mathbf r$. Small $\lambda$ is an aggressive Gauss–Newton step near the optimum; large $\lambda$ falls back to cautious gradient descent far from it; the demo raises $\lambda$ on a step that fails and lowers it on a step that helps. This replaced a naïve coordinate descent that stalled in the hundreds of microns.
  • A merit sampled over 3 fields × 7 wavelengths. Scoring only the two displayed panels (center + edge, R/G/B) lets the optimizer cheat: sharpen what is measured, ignore the rest. The merit it actually minimizes samples three field points (center, 0.7 zone, corner) across seven wavelengths spanning the visible, so chromatic and mid-field errors are genuinely paid for.
  • Sign-free curvature. Each surface is optimized in curvature $c=1/R$, allowed to pass through zero (a flat) and change sign: the ray-trace is smooth through flat, so this lets the optimizer bend an element freely and even flip a surface, which matters because you can type in an arbitrary starting design and it should still be improvable.
  • Basin-hopping (multi-start). The merit landscape is riddled with local minima (this section's global search), so a single damped-least-squares descent only polishes the basin it started in, which is why an unlucky start could end mediocre. The demo therefore perturbs the design and re-converges several times, alternating between jittering the best lens found and restarting from the original, and keeps the best result, a miniature of the "Hammer"/global-synthesis hops the commercial tools run overnight. With it, the triplet and Tessar reliably reach a few tens of microns; without it they would sometimes get stuck. A singlet still cannot be fixed no matter how hard you hop. That is physics, not the optimizer giving up.

From hand calculation to software⧉

optional

This optimization was being done long before there were computers to do it, by hand, and it was slow.

The old-fashioned way. Before electronic computing, designers traced rays by hand, one ray at a time, using trigonometric and logarithm tables to evaluate Snell's law at each surface, later with mechanical calculators and then early electronic ones. A single ray through a multi-element lens was minutes of careful arithmetic; a useful evaluation needed many rays; and the "optimizer" was the designer's own trained intuition about which curvature to nudge next. The pace depended on prescription complexity and calculation aids, and a finished design could take months. The classic lenses of the field (the achromatic doublet, the Cooke triplet, the double-Gauss) were all found this way, by people who had internalized how each aberration responded to each surface and steered the design largely in their heads. That this was possible at all shows how much structure the problem has; that it was so slow is why the field was transformed the instant computers arrived.

Today. Modern optical-design software does the same three things (forward model, merit function, iterative optimizer) at a scale no human can match. The industry-standard packages are Zemax OpticStudio, Keysight CODE V, and OSLO. They ray-trace thousands of rays per evaluation of the merit function, and they drive the parameter vector with damped least squares, a Levenberg–Marquardt-style update that you will recognize from Part 6, Linear methods and Fourier analysis. The "damped" part matters: a pure least-squares step on this strongly non-linear problem can overshoot into nonsense (a surface flips sign, an element collapses), so the damping factor blends the aggressive least-squares step with a cautious gradient-descent step, taking bold steps when the local quadratic model is trustworthy and timid ones when it is not. The optimizer needs the derivatives of every ray error with respect to every parameter, the Jacobian, which the software gets either by finite differences (perturb each parameter, re-trace, see how the spots move) or by differentiating the trace; assembling that Jacobian is most of the cost of each iteration.

How people actually use it. In practice a designer almost never starts from a blank sheet. A design session opens by loading a starting point: a lens from the program's built-in library, a scaled version of an existing design, or, very often, a competitor's design copied from a patent (many lens patents include numerical example prescriptions, though these need not be the final production design). With a sensible form on the screen, the designer sets up the problem, not the answer: the field points (center to corner), the wavelengths and their weights, the aperture/f-number, and then declares which of the lens's numbers are variables the optimizer may move and which are pinned, often by a solve, a rule that recomputes one parameter automatically to hold a property fixed (a back-focal-distance solve to keep the image in the right place, a curvature solve to hold the focal length). Next comes the merit function: usually the software's default RMS-spot or wavefront-error merit, then hand-added operands for the things the default ignores: cap the distortion, hold an edge thickness positive, bound the total length, favor a glass that is cheap and available. Only then does the designer hit optimize: damped least squares improves the local design, with convergence and runtime depending on the prescription and constraints, the designer reads the result off spot diagrams, ray-fan plots, and the MTF curve, adjusts weights or frees another variable, and re-runs, a tight, interactive loop in which the optimizer does the arithmetic and the human supplies the judgment about which compromise to chase. When local descent stalls, they unleash the global search (Zemax's "Hammer," CODE V's global synthesis) and let it grind for hours or overnight, hopping between basins; and when a design is finally good, they tolerance it and export the prescription to mechanical CAD and stray-light analysis. The craft changed when the computer arrived: it moved up a level, from tracing rays by hand to steering an optimizer that traces millions.

Because the merit-function landscape is riddled with local minima (many distinct lens forms that are each locally optimal), damped least squares alone only polishes whatever design region you start it in. So the software adds global search strategies (saddle-point methods, simulated-annealing-style hops, large libraries of starting designs) that deliberately jump between basins to find genuinely different and better lens forms, not just the nearest tidy minimum. And once a good design is found, the software runs tolerancing: it perturbs every parameter by realistic manufacturing errors (a radius off by a fraction, an element decentered, a spacing loose) and checks that the merit function does not blow up, because a design that is only optimal when built perfectly is worthless on a production line. Optimizing for robustness to manufacturing error is itself a regularization of the design, in spirit identical to preferring a flat, wide minimum over a sharp, brittle one.

The main point is simple: it is the same machinery as the rest of the book. A forward model that predicts an outcome from parameters; a merit (loss) function that scores the outcome; an iterative optimizer with regularization and a search strategy that drives the parameters down the loss. Swap "ray-trace" for "convolution" and "lens" for "image" and you are back in the inverse-problems chapter. Lens design applies the same optimization structure in optics.

Tradeoffs: the design is always a compromise⧉

optional

If the merit function could be driven to zero, lens design would be a solved, dull problem. It cannot, and the reason is that the design lives under hard constraints while several desirable axes pull against each other. A lens cannot maximize sharpness, speed, compactness, and low cost at the same time. The clear-eyed picture of a lens is a point on a Pareto front, a surface where improving any one quality necessarily worsens some other (Figure 22.4.5).

The axes that fight:

This is where computation helps. If the optics is allowed to be merely good enough and cheap rather than perfect, software can finish the job: the lens-profile correction and deconvolution of the Aberrations chapter undo residual distortion, vignetting, and even some blur after the fact. The effect is to shift the operating point along the Pareto front by accepting an optical design that is a little softer or a little more distorted, when the residual remains within the reconstruction pipeline's capabilities, and spend the savings on size, speed, or cost. Lens and algorithm split the work.

fig-lens-design-tradeoff
Figure 22.4.5 (reproduced). The lens-design Pareto cartoon. The competing qualities, speed (low f-number), small size/weight, low cost, and high sharpness, are drawn as axes pulling against one another. No design reaches the ideal corner where all are maximized; every real lens is a point on the trade-off surface, where buying more of one quality spends another (a faster lens grows larger and pricier; a cheaper lens softens). Computational correction shifts the chosen operating point: let the optics be cheaper or smaller, and recover sharpness or geometry in software afterward.

The end-to-end turn. A stronger version of this idea, and the one the Advanced part develops in full, is to stop optimizing the optics in isolation at all. Classical lens design minimizes a merit function defined on the optics (spot size, wavefront error) as if a sharp geometric image were the final product. But it is not: the sensor and a reconstruction algorithm come after the glass, and what we actually care about is the quality of the final picture. So make the whole pipeline, including the lens, sensor, and reconstruction network, differentiable end to end, and optimize the merit of the output image, with the optical parameters and the algorithm's parameters trained jointly. When you do this, the optimizer is free to discover lenses that look "wrong" by classical optical metrics (a deliberately blurred or coded PSF, a design no hand-calculator would ever have drawn) because that PSF, paired with its matched reconstruction, yields a better final image than a classically sharp lens would. This is the same optimization machinery once more, now with the loss moved all the way to the end of the pipeline and the lens treated as just another layer of learnable parameters. Coded apertures, wavefront coding, and differentiable optics in the Advanced part are this idea carried to its conclusion, the ultimate expression of optics and computation as two ends of one design space.

Tolerancing: from the nominal design to a manufacturable one⧉

optional

Everything so far has quietly assumed a perfect world. The optimizer hands back a prescription (a table of radii, thicknesses, glasses, and air gaps) and the spot diagrams that go with it are computed as if every one of those numbers were realized exactly, every surface ground to its ideal sphere, every element seated dead-center on the axis. Call that the nominal design. The trouble is that no shop builds the nominal design. A radius comes off the grinder a fraction of a percent off target; the glass in this particular melt has an index a few parts in ten thousand from the catalog value; an element sits a few microns decentered in its barrel and a hair tilted. A design that is paper-sharp at the nominal can be junk on the bench. Tolerancing is the discipline that closes this gap: it budgets the inevitable errors, predicts how the lens will actually perform once those errors are baked in, and (this is the part that surprises people new to the field) it is very often what really sets the cost and the element count, far more than the nominal design ever did. Two lenses can have nearly identical nominal performance and differ tenfold in price because their manufacturing tolerances, materials, assembly, and quality-control requirements differ.

The error sources. It helps to enumerate what actually goes wrong, because each entry is a parameter the optimizer treated as exact and the factory cannot. Surface by surface, the radius of curvature comes out slightly wrong (the tool wears, the polish runs long); each thickness and air-gap spacing lands within some machining and assembly tolerance; the glass index and dispersion vary not just by manufacturing slop but melt to melt: the same catalog glass type, poured in different batches, differs measurably, which is why precision lenses are sometimes recomputed for the measured index of the actual melt. On top of those per-number errors are the shape and placement errors the prescription does not even list: wedge (the two faces of an element not quite parallel/coaxial, so it acts like a weak prism), surface irregularity (the polished surface departing from a perfect sphere: bumps and astigmatic figure the test interferogram catches), and, at assembly, the decenter and tilt of each element, and its roll when the element is not rotationally symmetric. The decenters and tilts are usually the most damaging because they break the rotational symmetry the design relied on: a perfectly centered system has no on-axis coma, but a decentered one does.

Sensitivity analysis versus Monte Carlo. With a list of error sources and a guess at how big each can be, there are two complementary questions to ask, and the software answers both. The first is sensitivity analysis: perturb one tolerance at a time, re-evaluate the merit function (or the MTF), and see how much the performance moves. This ranks the tolerances. It tells you which of the many parameters drive cost most strongly, the ones whose tight tolerance you are really paying for, and which can be sloppy with no consequence. The second question is statistical: given the whole distribution of errors at once, what does the population of as-built lenses actually look like? That is answered by Monte Carlo analysis, which draws many random lenses, each with every parameter perturbed by a random draw from its tolerance distribution, evaluates each, and builds up the distribution of as-built performance. From that distribution you read the yield: the fraction of production lenses that will clear the acceptance threshold (Figure 22.4.6). Sensitivity analysis tells you where to spend your tolerance budget; Monte Carlo tells you what you will actually ship and at what scrap rate. The two together are how a design that looks fine on paper is judged buildable or not.

Compensators. The lever that makes tight tolerances affordable is the compensator: a small number of adjustments deliberately left free, to be set per unit at assembly, that absorb the accumulated error. The most common is simply refocus: many cameras can refocus, so the nominal back-focal distance need not be held perfectly; the factory (or the autofocus) takes up the slack. Beyond that, a designer may leave one air-space adjustable, to be shimmed to its best value while the lens is on the test bench, or leave one element's centering free to be shimmed or actively aligned until the on-axis image is clean. Because a compensator can claw back the performance that the random errors threw away, some other tolerances can be loosened, according to the modes of error the compensator actually corrects. Loosening tolerances is exactly how a lens gets cheaper. Tolerancing is therefore not just a pass/fail check at the end; it feeds back into the design, sometimes pushing the designer to add an element or rearrange the form specifically to make the lens tolerant, even at a small cost in nominal performance. The nominal design, the one optimized in the previous sections, is often the easier part. Obtaining good nominal spot diagrams is only part of the problem; what decides whether a lens is cheap, feasible, and shippable is its as-built performance and its yield. And this loops straight back to the theme of the chapter. One way to survive loose tolerances is to budget them generously and then lean on computational correction to recover the residual, the lens-profile correction and PSF deconvolution of the Aberrations chapter clawing back the distortion, vignetting, and softness that loosened tolerances let through. A lens that the pipeline is going to sharpen and de-distort anyway need not hold its corners to interferometric perfection on the production line. This is the same bargain as the Pareto shift above, now stated in the language of the factory: loosen the optics, lean on computation, and the cost falls. It is one more reason the pairing of cheap optics with computation keeps winning.

fig-tolerance-budget
Figure 22.4.6 (reproduced). From nominal to as-built. Left: a sensitivity-analysis bar chart, performance (MTF at a chosen frequency, or RMS spot) plotted as each tolerance is perturbed one at a time, ranking which errors (a particular surface's radius, an element's decenter or tilt, a melt-to-melt index shift) drive the loss and which are harmless. Right: a Monte-Carlo histogram of as-built performance, with the nominal design marked as a single sharp value, and around it the broad spread produced by drawing many random lenses with all tolerances perturbed at once, with an acceptance threshold drawn in so the shaded tail below it reads directly as the manufacturing yield. Adding a compensator (refocus, an adjustable air-space) narrows the spread and pushes more of the population above the line. (Deferred: to be generated.)

Focus⧉

Focus mechanics⧉

optional

Start with what "focus" physically is. The thin-lens conjugate relation from FUNDAMENTALS, $1/f = 1/u + 1/v$, ties the object distance $u$ to the image distance $v$ at which that object comes to a sharp point. An object at infinity ($u \to \infty$) focuses at $v = f$, right at the focal length; pull the object nearer and $v$ grows, so the sharp image moves back, away from the lens. To keep that sharp image pinned on a fixed sensor, then, the camera must move the lens (or a focusing group inside it, or the sensor) forward as the subject comes closer. That motion is focusing, and Figure 1 shows the geometry: focusing slides the system so that the chosen conjugate lands exactly on the sensor.

fig-focus-conjugate-move
Figure 22.8.1 (reproduced). Focusing = putting the chosen conjugate on the sensor. Side view of a thin lens with a fixed sensor plane. For a distant subject the sharp image sits near $v = f$; for a near subject the conjugate relation $1/f = 1/u + 1/v$ pushes the image back to a larger $v$. To keep that image on the sensor, the lens (or a focusing group) must translate forward. The figure shows two subjects at different depths and the corresponding lens positions that bring each to focus.

How far must the lens move? Write subject closeness as $D=1/u$, in inverse meters. The thin-lens equation gives

$$v=\frac{f}{1-fD},\qquad \frac{dv}{dD}=\frac{f^2}{(1-fD)^2}.$$

Near infinity, $fD$ is small and $\Delta v\approx f^2\Delta D$. Long lenses therefore need much more extension than short ones for the same change in subject diopters. The sensitivity grows as the subject approaches. A focus ring's allocation of angle depends on its mechanical or electronic mapping, but substantial optical travel is needed in the near field (Figure 22.8.2). This finite travel is what the focusing actuator must provide and calibrate.

fig-xkcd-1855
Figure 22.8.2 (reproduced). xkcd #1855 "Telephoto", Randall Munroe, xkcd.com/1855 (CC BY-NC 2.5).

Before autofocus existed, the photographer supplied that decision by eye, aided by a family of manual-focus aids (ground glass, the split-image and microprism screens, and the coincidence rangefinder) that make defocus visible; because they are as much about the photographer's craft as about optics, and because their disparity principle is the direct ancestor of phase-detection autofocus, they are covered with the photographer's focus controls in Chapter 5.3, Viewpoint, lenses, and focus (PHOTOGRAPHY part, §3.3).

Autofocus⧉

Contrast-detection AF⧉

in the book↗

The first algorithm is the most direct, and it needs no special hardware at all, just the imaging sensor the camera already has. The premise is a single observation about defocus: a sharp image contains more high-frequency energy than a blurred one. Blur is a low-pass operation; it smears edges, attenuates fine detail, and flattens the local contrast. So if you measure how much high-frequency content the image has and maximize it over lens position, a suitable metric usually peaks near the desired focus, provided the region contains usable detail and noise or processing does not dominate. This is contrast-detection autofocus (CDAF).

Concretely, the camera computes a contrast metric over the focus region: a sum of squared image gradients, or the energy passing a high-pass filter, or the variance of the local Laplacian. Any of these rises as the image sharpens and falls as it blurs, often tracing out a dominant peak, though texture, multiple depths, noise, or defocus transfer-function lobes can produce competing peaks as the lens sweeps through focus (Figure 22.9.1). Finding focus is then gradient ascent on the sharpness curve: climb until the metric stops increasing, and you are at the peak.

fig-contrast-af-curve
Figure 22.9.1 (reproduced). Contrast-detection AF: maximizing the sharpness curve. A plot of a contrast metric (sum of squared gradients / high-pass energy) against lens focus position. The curve is a single broad hill peaking at exact focus, falling off symmetrically into defocus on either side. Beside it, three thumbnail crops (far defocus, near focus, exact focus) show the corresponding rise in fine detail. An arrow traces the "hunting" path: the lens steps, the metric is read, and because a single sample gives no slope direction, the system must sometimes overshoot and reverse to locate the peak.

Contrast detection's strength is that it evaluates the recorded image directly: it reads the very sensor that will take the picture, so it avoids a separate AF optical-path mismatch. Metric choice, subject motion, noise, lens motion, and aperture-dependent focus shift can still affect accuracy. Its main weakness follows from the use of gradient ascent. A single measurement of the metric tells you the image's sharpness but not the slope of the hill. From one blurry frame the camera cannot tell whether focus lies nearer or farther: both directions look equally blurry. So it must hunt: nudge the lens one way, measure again, and infer the direction from whether the metric rose or fell, possibly reversing if it guessed wrong. This trial-and-error is visible as the lens racking back and forth before settling, it is slow, and it fails outright in low contrast or low light, where the hill is so flat that sensor noise swamps the metric and the peak is undetectable. Contrast AF is accurate but blind to direction. The next method fills that gap.

Phase-detection AF (the split-pupil / stereo trick)⧉

in the book↗

Suppose that instead of one view of the scene you had two, taken from two different parts of the lens's aperture. Then you would have a stereo pair, and stereo gives you not just that the subject is out of focus but which way and how far, in a single shot. This is the idea behind phase-detection autofocus (PDAF).

The geometry is straightforward. Light from a single subject point fills the whole exit pupil of the lens and converges toward the conjugate image point. If the sensor sits exactly at that convergence point, all the rays (from the left of the pupil, the right of the pupil, everywhere) pile onto one spot: in focus. But if the sensor is in front of the convergence point, the cone has not finished closing, and rays from the left half of the pupil land to one side while rays from the right half land to the other; the two half-pupil images are separated. If the sensor is behind the convergence point, the cone has crossed over, and the two half-pupil images separate the other way. The separation between the two half-pupil views is therefore a signed quantity: its sign tells you the direction of defocus (front or back), and its magnitude tells you how far out of focus you are.

A dedicated PDAF module makes those two views explicit. After the main lens, a small separator (secondary) lens, really a pair of tiny lenslets behind a mask, re-images the left and right halves of the exit pupil onto two separate line sensors. When the main lens is focused, the two line patterns line up. When it is defocused, the two patterns slide apart by an offset proportional to the defocus, with a sign set by the defocus direction (Figure 22.9.2). The camera correlates the two line signals to read off that lateral offset in one measurement, and from the offset it estimates the direction and size of a focus correction using a calibrated lens model. A confirmation or tracking update may still be needed; weak or repetitive texture can make the correlation ambiguous. This is why phase detection is faster than contrast detection.

fig-pdaf-principle
Figure 22.9.2 (reproduced). Phase-detection AF: stereo inside the lens. The exit pupil of the main lens is split into a left half and a right half. Behind the sensor plane a separator (secondary) lens re-images each pupil half onto its own line sensor. Three columns show front-focus, exact focus, and back-focus: at exact focus the two line patterns coincide; with front- or back-focus they shift apart, and the direction of the shift flips between the two cases. The lateral offset between the patterns is the disparity (signed defocus) read by correlating the two lines.
fig-autofocus-demo
Figure 22.9.3 (reproduced). Interactive: the two autofocus strategies, side by side. Contrast detection (CDAF): a scene blurred by a defocus disk whose size is the focus error; the demo plots a sharpness metric ($\sum|\nabla I|^2$) against focus position (one broad hill peaking at focus) and, on a button press, hill-climbs to the peak (step, measure, reverse if it dropped) so you watch it hunt, and a low-contrast/low-light toggle flattens the hill so it hunts and fails. Phase detection (PDAF): the two half-pupil line signals slide apart by a signed disparity proportional to defocus; correlating them reads the offset and drives straight to focus in one shot, no hunting. Flip between the tabs to feel why phase detection is fast where contrast detection dawdles.

PDAF uses a stereo-like measurement inside one lens. The effective baseline is the separation between the pupil regions' centroids, not the physical separation between neighboring sensor photodiodes. Unlike ordinary parallel-camera stereo, the disparity is zero at the current focus distance $Z_f$, not at infinity. In a thin-lens model with sensor distance $v$ and effective pupil baseline $B$, one sign convention gives

$$ d\approx vB\left(\frac1Z-\frac1{Z_f}\right). $$

Here $d$ is a signed separation on the sensor and $Z$ is object distance; divide by pixel pitch for disparity in pixels. Swapping the half-pupil labels reverses the sign. Compound lenses and separator optics require calibration of the scale, zero, and focus-motor response. This signed inverse-depth difference is why PDAF can suggest which way to move from a single exposure.

The classic implementation lives in the SLR. The main reflex mirror is partly transparent; behind it a small sub-mirror angles a fraction of the light downward to a dedicated PDAF module in the floor of the mirror box, with its separator lenses and line-sensor arrays (often arranged in a cross or a grid of points across the frame). This gives the fast, single-shot focus that made action and sports photography practical with autofocus. Its drawback is structural: the AF sensor is on a separate optical path from the imaging sensor, so any mechanical discrepancy between the two shows up as front- or back-focus error that must be calibrated out per body and per lens. Move the focusing function onto the imaging sensor itself and that separate-path mismatch disappears, though pupil and lens-response calibration remain, which is the next step.

On-sensor PDAF and dual-pixel AF⧉

optional

Phase detection's payoff (signed, single-shot focus) is too good to leave stranded on a separate module, especially once cameras went mirrorless and lost the sub-mirror entirely. The fix is to capture the two pupil halves on the main imaging sensor, so the same pixels that take the picture also report phase. There are two ways to do it.

The first is masked (phase-detect) pixels. Scatter a sparse set of special pixels across the imaging array, each with half of its light-collecting area masked off, some masked on the left, some on the right. A left-masked pixel sees only light coming from the right half of the pupil, and vice versa; pairing nearby left- and right-masked pixels recovers the two half-pupil views directly on the recording sensor. This brings PDAF to mirrorless and live-view shooting without a separate AF module and its optical-path alignment. The cost is that masked pixels are partially blind (they collect less light and must be interpolated over in the final image, like defective pixels), so they are kept sparse, which limits how dense and low-light-capable this flavor of on-sensor PDAF can be.

The second way wastes no light at all: dual-pixel autofocus. Instead of masking, split every photosite into two side-by-side half-photodiodes sharing one microlens (Figure 22.9.4). The microlens, the same per-pixel microlens stack introduced in FUNDAMENTALS, focuses the incoming cone so that the two half-diodes respond preferentially to opposite pupil regions; the left/right correspondence depends on the ray geometry and labeling convention. Each pixel is therefore its own miniature phase-detect pair, and the architecture can provide dense phase samples; the active AF area and readout selection depend on the camera and mode. Compare the left-diode image to the right-diode image across the frame and you get a dense disparity signal (phase detection at every point), which is why dual-pixel AF is fast and tracks well across the whole frame. For the final photograph the two halves are simply summed into a normal pixel value, so no light and no resolution is thrown away.

That same dense disparity is also a depth signal: the two half-pixels form a stereo pair with an effective baseline set by the pupil, often on a millimeter scale in phone cameras, enough to read a coarse per-pixel depth. Google's Portrait Mode (Wadhwa et al. 2018) turns it into synthetic bokeh: combine the noisy dual-pixel depth map with a learned person-segmentation mask, then apply a depth-dependent blur so the subject stays sharp while the background melts away. A single small phone camera fakes the shallow depth of field of a fast portrait lens, from autofocus hardware that also provides a useful depth cue, at a cost in readout, calibration, and computation (the depth-from-defocus story the chapter closes on, pushed all the way to a product).

fig-dual-pixel-af
Figure 22.9.4 (reproduced). Dual-pixel AF: every photosite is a phase-detect pair. Cross-section of one photosite under its microlens, with the photodiode split into a left half and a right half. The microlens directs rays from the left of the exit pupil onto the right half-diode and rays from the right of the pupil onto the left half-diode, so the two half-diodes see the two pupil halves. Across the array, the "left image" and "right image" formed by all the half-diodes are a stereo pair whose disparity is the per-pixel defocus; summing the two halves recovers the ordinary image with no light lost.

The disparity these dense methods produce is both a focus signal and a low-resolution depth signal. Because the baseline is just the small split across a single lens's pupil, the disparities are tiny and the depth map is coarse and noisy, far weaker than a wide-baseline two-camera rig. But it is real depth, captured by the main sensor in one exposure, and it is exactly what feeds portrait-mode background blur and small post-capture refocus on phones (forward-ref to the computational-DoF treatment in Depth of field and the light-field part). The same disparity that aims the lens also begins to measure the scene, which brings us to the explicitly computational siblings of autofocus.

Depth from focus / defocus, and learned subject AF⧉

optional

Autofocus reads defocus to remove it. If you use defocus to measure the scene, the same physics becomes a depth sensor. Two classic recipes do this.

Depth from focus (DfF) sweeps the lens through its whole focus range while capturing a stack of images, then asks, for each pixel independently, at which focus setting was it sharpest, using the very contrast metric from contrast AF, evaluated per pixel. The focus position of each pixel's sharpness peak maps directly to that pixel's depth, since each focus setting corresponds to one in-focus distance. It needs many exposures and a calibrated mapping from focus setting to distance, though it can avoid explicitly fitting a parametric blur kernel. Breathing, motion, and depth boundaries complicate correspondence across the stack. This is precisely the machinery behind focus stacking, which keeps the sharpest pixel from each slice to build an all-in-focus image rather than a depth map. The full treatment lives in Depth of field.

Depth from defocus (DfD) is the simpler alternative: rather than sweeping the entire range, take just two or a few images at different focus or aperture settings and infer, per pixel, the blur radius of the defocus disk. The geometry from FUNDAMENTALS' depth-of-field section ties that blur radius to distance-from-focus and aperture, so estimating the blur recovers the depth, from a handful of shots instead of a full stack (Figure 22.9.5). The foundational work is Pentland's 1987 method and Subbarao's contemporaneous analysis; both estimate the local point-spread function (PSF) and solve for the depth that explains it. That defocus PSF is also the bridge to deconvolution: if you know the blur, you can both read depth from it and undo it, tying DfD to the deblurring and aberration-correction machinery in Aberrations correction.

There is a third use of the same physics, halfway between measuring depth and aiming the lens: depth from defocus as autofocus, the trick behind Panasonic's DFD (Depth From Defocus) system. Rather than build a depth map at all, it uses defocus to drive focus. The camera carries a stored model of how a given lens's blur PSF changes with focus, captures two frames at slightly different focus settings, and compares them against that model to infer not just that the image is defocused but the direction and amount of the defocus, a PDAF-like, near-single-step cue extracted from an ordinary contrast-detect sensor with no phase pixels on the array. In effect it recovers phase detection's signed error from defocus comparison alone. It rides on top of CDAF (confirming focus at the sharpness peak) and can reduce the search needed by ordinary contrast AF. Continuous-video behavior still depends on motion, texture, lens drive, and focus confirmation; it is not a guarantee of hunting-free tracking. Some newer Panasonic systems combine DFD with on-sensor phase detection. Its weakness is the dependence on a per-lens blur profile (so it works only with characterized lenses) and on the subject holding still between the two frames.

fig-depth-from-defocus
Figure 22.9.5 (reproduced). Depth from defocus: blur radius to depth. Two captures of the same scene at different aperture (or focus) settings, in which an out-of-focus point renders as a disk whose radius depends on its distance from the focal plane. The change in disk radius between the two captures, measured per pixel, pins down the local blur, and the depth-of-field geometry converts that blur radius into a depth. A resulting per-pixel depth map is shown beside the input pair. Far fewer shots than a full focus sweep, at the cost of relying on a blur model.

The final step moves the decision about what to focus on from optics into recognition. Everything so far answers "how do I make this point sharp?" But choosing which point is the photographer's real intent, and modern cameras increasingly learn it. Subject and eye autofocus runs a detector (for human faces and eyes, for animals (their eyes specifically), for birds, vehicles, and trains) over the live feed, picks the subject (a person's near eye, say), tracks it as it moves, and then drives the underlying PDAF to focus on exactly that point. The focusing physics is unchanged; what is new is that AF's decision layer is now a recognition problem, solved by the learned-detection methods developed in Part 7, Probabilistic Approaches and Machine learning and Part 28, Photo collections. Alongside this learned, passive path sit the active rangefinders cameras have used over the years to assist focus rather than choose it: early infrared and ultrasonic systems (the Polaroid sound-ranging (SONAR) camera famously pinged the subject with ultrasound), and today's LiDAR / time-of-flight modules on phones that supply a direct depth measurement to seed and confirm focus in the dark, where contrast and phase signals both fade. This section ends where the book's main themes meet: optics provides the signal, computation reads it, and a learned model decides what the picture is of.

Where to focus: saliency, faces, and eyes⧉

optional

Everything above answers how to make a chosen point sharp; this section is about which point, because on a modern camera that decision is itself a vision problem. The oldest answers are crude heuristics baked into multi-point AF: focus on the center, or on the nearest object (closest-subject priority, betting the photographer wants the thing in front), or let the user tap a point: touch-to-focus, the clearest signal of intent. These work, but they are guesses about attention, and the better a camera can predict where a person would look, the less it has to guess.

That prediction is visual saliency: the same models, developed for human vision, that score each location by how much it draws the eye (contrast, faces, motion, the things that pop out; tied to the attention and eye-tracking material in Part 2, Fundamentals and the scanpath discussion there). A saliency map gives the camera a default answer when no specific subject is recognized: focus where the picture is most likely about. In practice, though, the single most reliable salient thing in a photograph is a person, so face detection became the first widely deployed "smart" AF. Early compacts ran a Viola–Jones-style cascade Viola & Jones 2004 (the boosted Haar-feature detector from the matching part) to box faces in real time and focus on them; today a learned detector (Part 7, Probabilistic Approaches and Machine learning) finds not just faces but eyes, and not just human ones (animal-eye and bird-eye AF, vehicle and train detectors), then drives the underlying phase-detect AF to lock the near eye, the point that usually matters most in a portrait, and tracks it as the subject moves. The focusing physics is untouched; what is new is that AF's decision layer is a recognition-and-saliency problem, solved by the learned methods of the computational-tools and big-data parts.

One older idea closed the loop with the photographer's own attention: eye-controlled focus. Canon's EOS film bodies (and the revived EOS R3) track the position of the photographer's eye in the viewfinder and place the AF point wherever they are looking, saliency measured directly off the user instead of predicted from the scene. It is a small, telling reminder that "where to focus" is ultimately a question about a human's gaze, and the camera can either model that gaze from the image or simply watch the eye behind the finder.

Glare suppression⧉

Where stray light comes from: flare, ghosting, veiling glare⧉

optional

Start with the single fact that drives everything in this chapter: at every air–glass interface, some light reflects. How much is given by the Fresnel equation for reflectance at normal incidence,

$$ R = \left(\frac{n_1 - n_2}{n_1 + n_2}\right)^2, $$

where $n_1$ and $n_2$ are the refractive indices on the two sides of the surface. For an ordinary air-to-glass interface, $n_1 = 1$ (air) and $n_2 \approx 1.5$ (a typical crown glass), so

$$ R = \left(\frac{1 - 1.5}{1 + 1.5}\right)^2 = \left(\frac{-0.5}{2.5}\right)^2 = 0.04, $$

about 4% per surface. That number is small but not negligible, and it drives the whole problem. The other 96% refracts through and forms the image; the 4% reflects back into the lens and can create artifacts.

Ghosts. Consider a strong light source (the sun, a streetlamp, a bright reflection) somewhere in or near the frame. Its rays enter the lens and most of the light proceeds normally toward the sensor. But suppose a ray reflects off one surface (losing 96%, keeping 4%), travels back, then reflects again off a second surface (keeping 4% of that), and now heads forward toward the sensor a second time. This doubly-reflected beam has lost the vast majority of its energy (it carries roughly $0.04 \times 0.04 = 0.0016$, less than two-tenths of one percent of the source) but if the source is very bright, that residue is still visibly bright. And because it has traversed the optics along a bent path, it does not focus where the source's real image is. Instead it forms a ghost: a discrete, usually defocused bright blob, frequently shaped like the aperture (because the out-of-focus image of a bright point takes the shape of the diaphragm, recall the bokeh discussion of Depth of field), and typically strung out along the line from the source through the center of the frame, often mirrored to the opposite side. A whole chain of ghosts appears because there are many pairs of surfaces, each pair producing its own double-reflection at its own position. (Figure 22.1.13)

fig-lens-flare-ghosting
Figure 22.1.13 (reproduced). How a ghost is born. A bright source (e.g. the sun) sends rays into a multi-element lens. Most light refracts straight through to form the image. One ray is traced reflecting off a rear surface, traveling back, reflecting a second time off a front surface, and then proceeding to the sensor along a bent path: this double reflection lands as a defocused, aperture-shaped ghost displaced from the source, typically along the source-to-center axis. Several such surface pairs produce a chain of ghosts, and the unfocused remainder adds a low-frequency veiling wash across the frame. The single traced double-bounce is highlighted; faint replicas indicate the other surface pairs.

Flare. When the bright source is just outside the frame, its light still enters the front of the lens at a steep angle and reflects or scatters inside the barrel without forming a clean ghost. The result is streaks, arcs, and a generally washed-out region spilling in from the side where the source sits. This is what photographers loosely call flare: the splashy, often colorful artifact you get shooting toward a light just off the edge of the picture. (Some lens designs, the anamorphic optics of Special optics among them, flare in such a characteristic way that the look is now imitated on purpose.)

Veiling glare. Not every stray ray forms a recognizable ghost or streak. Most of the misdirected light (the countless weak reflections off every surface, plus scatter off the diaphragm blades, the barrel walls, dust, and microscopic imperfections in the glass) does not concentrate anywhere. It just spreads, more or less uniformly, a thin layer of light over the whole image. This is veiling glare: a low-frequency wash that lifts the blacks and crushes the contrast of the picture. It is the most damaging form of glare precisely because it is invisible as an artifact (there is no obvious blob to point at) yet it quietly robs the image of its deep tones. A shadow that should be black instead reads as dark gray; a scene shot into backlight looks flat and milky. Veiling glare is worst when a bright source sits just outside the frame (so the hood, below, is the first defense) or when you shoot directly into the sun.

Why compound lenses make it worse. Here is the part that ties back to Compound lenses and explains why coatings are not optional but mandatory. The ghost-producing mechanism needs a pair of surfaces: light reflects off one, then off another. If a lens has $N$ air–glass surfaces, the number of distinct surface pairs that can produce a double-reflection ghost is

$$ \binom{N}{2} = \frac{N(N-1)}{2} = O(N^2). $$

The count of candidate two-reflection paths grows quadratically; many are blocked or too weak or defocused to appear as separate visible ghosts. A simple triplet has six surfaces: fifteen pairs. A modern fast zoom can have thirty or forty surfaces, which is hundreds of potential ghost paths, and on top of that the cumulative veiling glare grows with the number of surfaces too. Worse, recall from Compound lenses that the T-stop already penalizes a lens for its transmittance loss $\tau$: with 4% lost to reflection at each of, say, thirty surfaces, an uncoated lens would transmit only $0.96^{30} \approx 0.29$: under a third of the light would reach the sensor, and the remaining light would be reflected away, absorbed, or contribute to stray paths. Only a fraction becomes recorded glare. Such losses and ghosts strongly constrain complex uncoated designs. This is the problem that coatings solve, and the entire era of complex, high-element-count photographic lenses was made possible by the coating.

Hardware suppression⧉

optional

The hardware cures attack glare at two different stages. The coating reduces the reflection at each surface, so less stray light is generated in the first place. The hood and baffles are geometric: they prevent off-axis light from ever entering the system, so it cannot scatter. First, coatings.

Anti-reflection (AR) coatings. The reflection at a single surface comes from the abrupt jump in refractive index from $n_1$ to $n_2$. The idea of an anti-reflection (AR) coating is to deposit a thin transparent film on the glass so that the light now meets two closely-spaced interfaces (air-to-film and film-to-glass) and to arrange for the two faint reflections from those interfaces to cancel each other by destructive interference. Two conditions make the cancellation as complete as possible.

The first condition is on the film's thickness. The reflection off the film's front face and the reflection off its back face travel paths that differ by twice the film thickness (down and back up). For the two reflected waves to arrive exactly out of phase (crest meeting trough, so they subtract), that extra round-trip path should be half a wavelength. The film thickness must therefore be a quarter of a wavelength (down a quarter and back up a quarter makes a half-wavelength round trip), measured inside the film:

$$ d = \frac{\lambda}{4 n_c}, $$

where $n_c$ is the film's index and $\lambda$ the wavelength in vacuum. This is the famous quarter-wave condition.

The second condition is on the film's index $n_c$, and it makes the two reflections not just opposite in phase but equal in amplitude, so they cancel completely. The reflection at the air–film interface has reflectance $((n_1 - n_c)/(n_1 + n_c))^2$ and the reflection at the film–glass interface has reflectance $((n_c - n_2)/(n_c + n_2))^2$. Setting these equal works out to the condition that the coating index should be the geometric mean of the indices it sits between:

$$ n_c = \sqrt{n_1 n_2}. $$

For an air-to-glass surface ($n_1 = 1$, $n_2 \approx 1.5$) this asks for $n_c = \sqrt{1.5} \approx 1.22$. Real coating materials only approximate this (magnesium fluoride, the classic single-layer coating, has $n_c \approx 1.38$, a bit high) but even an imperfect match drops the per-surface reflection from ~4% to around 1–1.5%, a large win.

The catch with a single quarter-wave layer is that both conditions hold exactly only at one wavelength (the one $\lambda$ that makes the film a true quarter-wave) and one angle of incidence; away from that wavelength the cancellation is partial, which is why a single-coated surface reflects a faint residual color: the coating is tuned to null green, say, and leaks a little blue and red, giving the surface a purple sheen. The fix is a multi-layer coating: a stack of several films of alternating index, whose combined interference can be engineered to suppress reflection across the whole visible band and over a range of angles. This is the colored, oily sheen you see on the front of a modern lens: each visible tint is the small residual reflection the stack could not quite kill. Multi-layer coatings push the per-surface reflectance down to ~0.1–0.5%, and that is the number that made the thirty-surface zoom practical: at 0.3% per surface, thirty surfaces transmit $0.997^{30} \approx 0.91$ instead of 0.29, and the glare budget shrinks by more than an order of magnitude. (The detailed multilayer theory belongs to the FUNDAMENTALS lens-coating history; here we have done the one-layer physics and named the multilayer generalization. The history of who first discovered coatings, and how the method spread during and after the war, is in the sidebar below.) (Figure 22.10.1)

fig-ar-coating-interference
Figure 22.10.1 (reproduced). Anti-reflection coating by destructive interference. Left, a single quarter-wave layer: an incoming ray partially reflects at the air–film interface and at the film–glass interface; the two reflected waves are drawn a half-wavelength out of step, so they cancel. The two conditions are annotated: film thickness $d = \lambda/4n_c$ (quarter-wave) and index $n_c = \sqrt{n_1 n_2}$ (geometric mean, equal amplitudes). Right, a multi-layer stack of alternating-index films broadens the cancellation across the whole visible band, with the small residual reflection shown as the characteristic colored sheen of a coated lens.

Lens hood. The simplest, cheapest, and often most effective anti-flare device does not touch the glass at all: it is a tube or petal of black plastic on the front of the lens. A lens hood blocks light from sources outside the frame from ever striking the front element. Since much of the worst flare and veiling glare comes from a bright source just off the edge of the picture, intercepting that light before it enters the lens removes the artifact at its origin. If the stray light never enters the lens, it cannot reflect or scatter inside it. The hood is shaped (the "petal" or "tulip" cutouts) so that it shades as deeply as possible without intruding into the rectangular field of view it must leave unobstructed. (Figure 22.10.3)

Internal baffles, blackened edges, and barrel paint. Inside the barrel, the remaining defense is to make every surface that is not supposed to carry image light as black and non-reflective as possible, and to physically block grazing rays. Internal baffles are rings and ridges machined into the barrel that stop a ray skimming down the inside wall from reaching the sensor; the edges of the glass elements are painted black so light cannot enter the glass from the side and pipe through it; and the whole inner barrel is finished with deep-black, often textured anti-reflective paint (and increasingly engineered ultra-black coatings). All of this matters most where the bright source is overwhelmingly stronger than the target, most dramatically in telescopes, and above all space telescopes, which must image impossibly faint objects with the unshielded sun or the bright limb of the Earth just out of the field. There, elaborate baffle tubes and light traps are as much a part of the optical design as the mirrors themselves (cross-ref Special optics, telescopes and reflecting systems). Blocking an overwhelming source so that a faint neighbor becomes visible is the coronagraph's job. A joke version of the same idea appears in (Figure 22.10.2). (Figure 22.10.3)

fig-xkcd-975
Figure 22.10.2 (reproduced). xkcd #975 "Occulting Telescope", Randall Munroe, xkcd.com/975 (CC BY-NC 2.5).
fig-lens-hood-baffles
Figure 22.10.3 (reproduced). Geometric stray-light control. A lens with a petal hood on the front: rays from a source inside the field of view pass freely, while a ray from a bright source just outside the frame is intercepted by the hood before reaching the front element. Inside the barrel, internal baffles (ridges) block a grazing ray skimming the wall, blackened element edges stop side-entry light, and the matte-black barrel paint absorbs scatter. An inset shows the same baffle principle scaled up to a telescope's baffle tube shielding the sensor from off-axis sunlight.

Computational deflare and glare deconvolution⧉

optional

Hardware leaves a residual level of glare: even a perfectly coated, hooded, baffled lens has some residual reflectance and scatter, and when you shoot straight into a bright source there is no hood angle that helps. The same optics-plus-software division applies here: reduce glare optically, then remove the remainder in software. Veiling glare can be modeled with the same PSF framework used for blur, so calibrated inverse methods can help, with additional difficulties from spatial variation, sources outside the frame, clipping, and photon noise.

Glare as a broad PSF. A useful approximation retains the direct image as well as the weak broad tail: $y\approx(1-\alpha)x+\alpha(k_g*x)+g+n$, where $k_g$ is a normalized broad glare kernel, $\alpha$ the fraction assigned to it, $g$ discrete ghosts or contributions from outside the modeled field, and $n$ noise. This convolution assumes approximately shift-invariant glare; a general calibration uses a space-varying transport operator. Where an aberration's PSF is a small, tight blur (it spreads a point a few pixels), the glare PSF is broad and shallow: a tiny fraction of each bright point's light is spread far and wide across the whole frame. That long, low tail is exactly the veiling wash. If you can measure this glare spread function (for instance by photographing a single bright point in a dark surround and recording how its light leaks across the rest of the sensor), then you can estimate the scattered component and solve for the direct image. Subtraction requires an estimate of both the spread function and the source image; subtracting the mean glare cannot remove its shot noise or recover clipped values. A particularly direct way to measure the glare is to place a structured occlusion mask between the scene and camera and acquire a sequence at different mask positions: the mask lets one separate the direct, image-forming light (rays that pass cleanly to their proper pixel) from the global veiling component (rays scattered inside the lens onto pixels where they do not belong), so direct and indirect transport can be separated without fitting one parametric glare kernel. Blocking bright contributions during capture also reduces their photon noise, which simple after-the-fact subtraction cannot do (Talvala et al. 2007). (Figure 22.10.4) Raskar and colleagues moved the mask into the camera, close to the sensor, where it samples the 4-D light field: the rays reaching a pixel from different parts of the aperture are recorded separately, glare shows up as outliers among them, and rejecting the outliers reduces glare in a single photograph, at a cost in spatial resolution Raskar et al. 2008 (glare-aware photography). This is the same calibrated, non-blind deconvolution of Aberrations correction (Wiener and regularized inverse filters), pointed at stray light rather than at the lens's own blur. The discrete ghosts, being lens-specific and source-position-specific, are harder to model as a single kernel and are usually handled separately (often by learned methods, below). (Figure 22.10.5)

fig-veiling-glare-2
Figure 22.10.4 (reproduced). Separating direct from global light to measure veiling glare. A structured occlusion mask placed between the scene and the camera splits the recorded light into a direct component (image-forming rays that reach their proper pixel) and a global component (the stray light scattered inside the lens onto pixels where no legitimate ray belongs). Isolating the global component gives a direct measurement of the veiling glare, which can then be subtracted without assuming any parametric blur kernel Talvala et al. 2007.
fig-veiling-glare-psf
Figure 22.10.5 (reproduced). Veiling glare as a point spread function. Left, on a log scale: the response of a lens to a single point is a bright core, all an ideal lens would produce, over a broad skirt about a hundredth of the peak that extends tens of pixels. Right: across an edge between a black region and a bright one, the skirts of all the bright points add up to a veil that raises the black side to a pedestal and lowers the contrast. Subtracting a measured skirt, or deconvolving by it, removes the pedestal.

Dehaze-style recovery and learned deflaring. A second, more model-free route treats veiling glare like atmospheric haze: both are a low-frequency additive wash that lifts the blacks, so the dehazing contrast-recovery methods (cross-ref dehazing) can suggest useful priors, but the forward models differ: atmospheric haze includes depth-dependent attenuation and airlight, whereas camera glare redistributes light within the imaging system. Contrast recovery alone is not a calibrated estimate of scene radiance. For the discrete artifacts (the chain of ghosts and the streaky flare) the pattern depends intimately on the particular lens, the source position, and even the aperture setting, which makes a hand-built model brittle; here learned flare- and ghost-removal networks have become the practical tool. Pairs of flared and clean images are hard to photograph, so they are made: Wu and colleagues added captured and simulated flare to clean photographs Wu et al. 2021 (flare removal), and the Flare7K dataset provides 7,000 synthesized nighttime flare patterns for the same purpose Dai et al. 2022 (Flare7K). Glare suppression matters especially for high-dynamic-range (HDR) capture: when you are trying to measure the faint, dark end of a scene that also contains a very bright source, veiling glare from that source contaminates exactly the dark measurements you care about, so removing it is essential to getting the shadows right (Talvala et al. 2007). Merging more exposures does not help, since every exposure contains the same glare in proportion: McCann and Rizzi found that glare, not the sensor, limits the range a camera can measure McCann & Rizzi 2007, and Chapter 17.1, Dynamic range and multiple-exposure capture works through how much. Measuring and subtracting the glare restores the milky, contrast-robbed shadows to deep blacks (Figure 22.10.6), and doing so before assembling the exposure stack is what lets the recovered HDR image hold real detail in the dark tones next to a bright source (Figure 22.10.7). The full treatment of learned deflaring is forward-referenced to the Advanced part; here it is enough to see that glare, like aberration before it, is another case where moderate optical suppression plus computation works better than either approach alone.

fig-veiling-glare-12
Figure 22.10.6 (reproduced). Glare removal, before and after. A scene shot with a bright source before (left) and after (right) the measured veiling glare is subtracted: the flat, milky shadows that glare had lifted to gray are restored to deep blacks and the contrast returns Talvala et al. 2007.
fig-veiling-glare-14
Figure 22.10.7 (reproduced). The result for HDR. With veiling glare from a bright in-frame source removed, the faint dark end of the scene is measured correctly, and the recovered high-dynamic-range image holds detail in the shadows that glare had otherwise washed out Talvala et al. 2007.

Optical stabilization⧉

in the book↗

A hand-held camera is never quite still: muscle tremor, pulse, and the press of the shutter button rotate it by tiny, fast, more-or-less random angles. A short enough exposure freezes that quiver, but photography is an integration over time: the sensor accumulates light for the whole duration the shutter is open, so if the image moves across the sensor during that interval, every scene point smears along the path the image took. That smear is motion blur, and when its cause is the trembling camera rather than a moving subject, it is hand-shake blur.

The classic defenses are blunt: shorten the exposure (freeze the shake, but starve the sensor of light), or brace the camera (a tripod, a wall, your elbows on a table). Stabilization is the alternative. Instead of shortening the exposure or immobilizing the whole camera, it lets the camera shake but moves an optical element, or the sensor itself, to keep the projected image still on the sensor for the duration of the exposure. A small gyroscope feels the shake; an actuator pushes a lens group or the sensor in the opposite sense, just enough to hold the image in place. Done well, this buys several stops of slower shutter speed, which is a large amount of light and the difference between a sharp hand-held shot and a blurry one. The chapter develops the problem (the blur budget), the two optical mechanisms (lens-shift and sensor-shift), and the electronic and computational alternatives, ending on the limit that frames the whole part's relationship between optics and software: optical stabilization reduces camera-induced blur within its operating range; subject motion still requires suitable capture choices or adequate measurements for reconstruction.

The problem: hand-shake and the blur budget⧉

optional

Start with the geometry, because it explains why long lenses are so much harder to hold steady. Hand tremor mostly rotates the camera (small angular wobbles in pitch and yaw) rather than translating it bodily through space. (Translation matters too, especially up close, but rotation dominates for ordinary subjects.) Now recall from FUNDAMENTALS how a camera rotation maps to the image: rotating the camera by a small angle $\Delta\theta$ slides the projected image across the sensor by

$$\Delta x \approx f\,\Delta\theta,$$

where $f$ is the focal length, for small pitch/yaw rotations near the image center. Off-axis displacement depends on field position; roll produces a different motion field. The displacement is proportional to focal length. A $0.1°$ wobble already moves the image about $42\,\mu\mathrm m$ at $f=24\,\mathrm{mm}$ and drags it across many pixels on a long telephoto. This is the geometric heart of hand-shake blur: the same physical tremor of your hands produces a larger image-plane smear the longer the lens.

fig-handshake-motion-blur
Figure 22.11.1 (reproduced). Hand-shake motion blur: a tremor smeared over the exposure. Left: a stylized hand-tremor trajectory, the small, jittery angular path the camera traces during one exposure (pitch vs. yaw, a few tenths of a degree, with the squiggle of pulse and muscle tremor). Center: a single bright scene point projected through the lens; as the camera rotates by $\Delta\theta$, its image walks across the sensor by $\approx f\,\Delta\theta$, so over the open-shutter interval the point integrates into a streak that traces the tremor path. Right: two streaks side by side for a short lens and a long lens under the same tremor, the long-lens streak conspicuously longer, since blur $\approx f\,\Delta\theta$ grows with focal length. A caption notes that the blur also grows with shutter time, since a longer exposure integrates more of the path.

The smear also grows with exposure time, for the obvious reason: the longer the shutter stays open, the more of the tremor path the image integrates. Put the two together (blur grows with focal length and with shutter time) and you recover the old photographer's rule of thumb for hand-holding: keep the shutter time below about $1/f$ (for example, $1/200\,\text{s}$ on a $200\,\text{mm}$ lens). This is an empirical rule associated with 35 mm photography and a chosen final viewing size, not a guarantee of one- or two-pixel blur. Sensor pitch, crop, technique, stabilization, and acceptable sharp-frame probability change the useful threshold.

That rule exposes a tension we already met in FUNDAMENTALS as the blur budget inside the exposure triangle. You want a short shutter to freeze the shake, but a short shutter lets in less light, and the missing light has to be bought back somewhere. You can open the aperture wider (more light, but less depth of field, cross-ref Depth of field), or raise ISO to encode the shorter exposure more brightly (without collecting more light; the photon deficit remains, as the noise chapter explains). In dim conditions you may not be able to afford a shutter fast enough to freeze shake without paying an unacceptable price in depth of field or noise. The whole appeal of stabilization is that it relaxes the blur budget: by physically holding the image still, it lets you use a longer shutter (gathering more light) without the shake smear that a longer shutter would otherwise cause. It effectively permits longer exposures without additional shake blur.

One limitation matters throughout this chapter: stabilization fights camera motion only. It senses and cancels the motion of the camera. A subject that moves during the exposure (a running child, a passing car, wind-blown leaves) still smears across the sensor, and no stabilizer can help, because the stabilizer has no idea the subject is moving and would have to move the image differently for that part of the frame than for the rest, which a single rigid shift of the lens or sensor simply cannot do. Stabilization can hold the whole image still relative to the camera; it cannot hold one moving object still relative to its moving background. Freezing a moving subject is therefore a separate problem: either a faster shutter (back to the blur budget) or, after the fact, motion deblurring as an inverse problem (forward-ref to the deblurring chapter in Part 16, Deblurring). Keep this scope in mind: everything in this chapter buys sharpness against your hands, not against the world.

Optical stabilization: lens-shift vs. sensor-shift (IBIS)⧉

optional

To cancel image motion you need two things: to sense how the camera is moving, and to act to undo it. Both flavors of optical stabilization share the same sensing and differ only in what they move.

Sensing. The camera carries a tiny micro-electro-mechanical-system (MEMS) gyroscope, the same class of chip used in phones, that measures angular velocity about the pitch and yaw axes (and, in some systems, roll) hundreds or thousands of times a second. A gyroscope reports how fast the camera is rotating; integrating that signal estimates how far it has rotated. Often an accelerometer is paired with it (together they form an inertial measurement unit (IMU)) to help with low-frequency drift and translational shake. From the angular signal and the focal length, a controller computes the image-plane displacement the shake is about to cause (recall $\Delta x \approx f\,\Delta\theta$) and commands an actuator to produce the opposite displacement, so the net motion of the image on the sensor is driven toward zero. This runs as a tight feedback (control) loop: sense, compute the counter-motion, drive the actuator, repeat, fast enough to track the tremor in real time (Figure 22.11.2).

fig-gyro-feedback-loop
Figure 22.11.2 (reproduced). The stabilization feedback loop. A block diagram: a MEMS gyroscope / accelerometer (IMU) senses the camera's angular velocity → a controller integrates it and, using the focal length, computes the image-plane shift the shake would cause and the counter-shift needed to cancel it → an actuator (a voice-coil moving a floating lens group, or a magnetic stage moving the sensor) produces that counter-motion → the image on the sensor is held still, and its residual motion is fed back to close the loop. Arrows show the loop running continuously during the exposure; a side note marks that the loop's bandwidth (how fast it can react) and the actuator's travel range set the limit on how much shake it can absorb.

Acting, version one: lens-shift optical image stabilization (OIS). Put a dedicated floating lens group inside the lens that can slide laterally (perpendicular to the optical axis), driven by voice-coil actuators, the same kind of electromagnetic motor that moves a loudspeaker cone. Shifting that group sideways steers the whole projected image back to where it should be, opposing the shift the shake induced. Canon introduced this form of Image Stabilizer (IS) in an interchangeable SLR lens in 1995 (cross-ref the image-stabilization history in Chapter 1.1, From Digital to Computational Photography), and Nikon's Vibration Reduction (VR). Its advantages flow from being built into the lens: the correcting group is optimized for that specific lens (its focal length, its aberration behavior), and because the correction happens before the sensor, the stabilized image is what the viewfinder and the autofocus system see, a steadier view to compose and focus with. The cost is that every lens needs its own stabilization hardware, and a long zoom with a heavy floating group is expensive to build well. (Figure 22.11.3)

fig-ois-vs-ibis
Figure 22.11.3 (reproduced). Two ways to hold the image still: lens-shift vs. sensor-shift. Two side-by-side cutaway schematics fed by the same gyro signal. Left, lens-shift OIS: a floating lens group inside the barrel is driven sideways by voice-coil actuators (vertical arrows), bending the ray bundle so the image lands back on its original spot on a fixed sensor. Right, sensor-shift IBIS: the lens is rigid, and the sensor rides a magnetic stage that translates (and can rotate for roll) to chase the moving image. Each panel shows a single ray bundle from an off-axis point and how it is brought back to the same image location, one by moving glass, the other by moving silicon. A label notes that the two can be combined ("dual IS").

Acting, version two: sensor-shift in-body image stabilization (IBIS). Leave the lens rigid and instead mount the sensor on a small magnetic stage that can translate in the image plane (and, crucially, rotate about the optical axis) to follow the image as it moves. Because the moving part is in the camera body, IBIS can work with many mounted lenses, including old and adapted lenses with no stabilizer. Correct focal-length information, image-circle coverage, and mode compatibility still matter; manual lenses may require entering the focal length. And because the sensor can rotate, IBIS can correct roll (rotation about the lens axis), an axis a laterally-shifting lens group cannot touch; combined with the two translational shake components it is often described as 5-axis stabilization (pitch, yaw, roll, plus horizontal and vertical translation). IBIS and lens OIS are not mutually exclusive: many systems run both at once, with the lens correcting the axes it handles best and the body correcting the rest, a cooperation manufacturers market as "dual IS."

How many stops? The benefit is quoted in stops, meaning $\log_2$ of the ratio of shutter times the stabilizer lets you use. If stabilization lets you hand-hold at $1/15\,\text{s}$ where without it you would need $1/250\,\text{s}$ for the same sharpness, that is a ratio of about $16{:}1$, or $\log_2 16 = 4$ stops. Manufacturers quote several stops of benefit under specified test conditions; the result depends on lens, focal length, body, axis, and sharpness criterion. The number is not unbounded, and the ceilings are physical: the gyro and controller drift on low-frequency motion (slow sway is hard to distinguish from the camera being deliberately panned), the actuator has a finite travel range (it can only shift so far before it hits a stop), and for IBIS the moved sensor must stay inside the lens's image circle: push it too far and the corners fall off the projected image. Past those limits, residual blur creeps back in, which is one reason the burst-capture alternative at the end of the chapter exists.

Digital / electronic stabilization and the computational alternatives⧉

optional

Optical stabilization moves real hardware. The cheaper, hardware-free path is to correct the motion in the pixels after the fact: electronic image stabilization (EIS), also called digital stabilization. The idea is purely computational: estimate how the camera moved between frames (from the gyro, from optical-flow analysis of the image content, or both), then crop in by a margin and warp each frame so that successive frames line up: the wobble is absorbed into the margin you cropped away, and the visible frame stays steady (Figure 22.11.4).

fig-digital-vs-optical-stab
Figure 22.11.4 (reproduced). Electronic (digital) vs. optical stabilization. Top row, EIS: a sequence of video frames whose full sensor area jitters frame-to-frame; an inset "output window" is cropped inside each frame and re-positioned (and slightly warped) so the output sequence is steady, at a visible loss of field of view (the discarded margin) and with the warning that this acts between frames, not within one exposure, so it cannot remove the blur smeared into a single frame. Bottom row, optical (OIS/IBIS): the same shake canceled by moving the lens/sensor during the exposure, so each frame is captured sharp at full sensor resolution and full field of view. A side note marks the rolling-shutter caveat: on a complementary metal-oxide-semiconductor (CMOS) sensor the EIS warp must also un-skew rolling-shutter distortion.

EIS is attractive because it has no moving parts and costs nothing in hardware. It is software running on frames the camera already has. But it carries two real limitations. First, the crop-and-warp costs resolution and field of view: the margin you reserve for the correction is thrown away, so a digitally-stabilized video is narrower and (after up-scaling back to size) slightly softer than the raw capture. Second, and more fundamentally, EIS works between frames, not within a single exposure. It can align frame $n$ to frame $n+1$, smoothing the jitter of a video sequence, but it cannot reach inside one frame to undo the smear that the shake already baked into that frame's exposure. So EIS stabilizes the motion of the video without reducing the per-frame motion blur the way optical stabilization does. The two are complementary, and phones combine them: gyro-driven OIS to keep each frame sharp, plus gyro-plus-optical-flow EIS to glue the frames into smooth video.

There is one more wrinkle EIS must handle on modern sensors: the rolling shutter. A rolling-shutter CMOS sensor starts and ends the row exposures at successively shifted times, so during fast motion the top of the frame is captured a few milliseconds before the bottom, skewing straight verticals into slanted ones (the classic "jello" wobble, cross-ref the motion/video treatment of rolling shutter). Electronic stabilization that warps frames must therefore not only translate them to cancel shake but also un-skew the rolling-shutter distortion, which means the warp is a per-row geometric correction, not a single rigid shift. Getting this right is exactly what makes phone video look very smooth.

Finally, a complementary computational approach uses a different strategy. Optical stabilization answers the blur budget by enabling one long, stabilized exposure. The computational alternative answers it the opposite way: take a burst of many short, individually blur-free exposures and combine them. Each short frame is so brief that hand-shake cannot smear it (the shake is frozen, not canceled) but each short frame is also dark and noisy. So the burst is then aligned and merged: software estimates the small frame-to-frame offset the shake produced and shifts the frames back into register, then averages them. Averaging $N$ aligned frames cuts the random noise by a factor of $\sqrt{N}$ (recall the multi-frame denoising result), approaching the shot-noise performance of an equally long total exposure when registration succeeds and capture overhead is negligible. Read noise is paid once per frame, so in a read-noise-limited regime the burst is worse than one equally long unblurred exposure. Short frames must actually be short enough for the motion, and alignment or rejection can discard information. This align-and-merge burst pipeline (cross-ref the multi-frame denoising and super-resolution machinery) is how a phone with a tiny sensor and limited optical stabilization nonetheless produces sharp, clean low-light photographs: it replaces one long exposure with burst capture and alignment. It is the software counterpart of optical stabilization, and it is forward-referenced into the Advanced computational-camera part. Optics holds the image still with hardware, while computation holds it still with alignment. They are two ends of the same design space.

Assorted pixels⧉

Dual-pixel and phase-detect pixels: buying depth and focus⧉

optional

The most widespread assorted pixel sits in nearly every modern phone and mirrorless camera: the dual-pixel (or, more generally, phase-detection autofocus, PDAF) pixel. It supports autofocus and, as a bonus, provides a weak depth cue.

Recall that a single photosite ordinarily sits under one microlens and reports one number: the total light from the lens's whole exit pupil funnelled onto it. A dual-pixel splits the photodiode in two under that shared microlens, so the left half-diode collects light that came through the right half of the lens aperture and the right half-diode collects light from the left half (the microlens flips them). Each half therefore sees the scene from a slightly different viewpoint, forming a stereo pair with a baseline of about half the aperture, captured on one sensor with no second camera (Figure 34.1.2).

When the scene is in focus, both halves see the same image and their two signals line up. When it is out of focus, the two half-images are shifted relative to each other, and the sign and size of that shift, the phase difference, say how far out of focus the point is and in which direction (front or back). That is the whole principle of phase-detection autofocus: the camera estimates signed defocus from the sub-image disparity and uses it to drive focus. Calibration, low contrast, noise, and subject motion can still require further corrections. Because the split is at the pixel, this happens at thousands of points across the frame at once, at video rates. This is why on-sensor PDAF, developed further in Chapter 22.9, Autofocus, displaced the older dedicated AF modules.

For the final picture, the two halves are simply summed: both halves contribute to the image. Isolation, fill factor, and read-noise differences can prevent exact equivalence to an unsplit pixel. The depth information is encoded in the difference of the two halves. A quad-pixel (2×2 on-chip lens) variant splits into four, adding vertical as well as horizontal phase so the sensor can focus on horizontal edges too.

That same left/right pair is a tiny two-view light field, and the per-pixel disparity between the two views is a low-baseline defocus cue that becomes metric depth only with optical calibration, including the lens focus setting. This is the basis of single-camera depth-from-dual-pixel, which powers phone portrait modes: learn to turn the subtle dual-pixel disparity into a clean depth map, then synthesize background blur [@garg-etal-2019; @wadhwa-etal-2018]. The same dual-pixel data also drives single-image defocus deblurring Abuolaim & Brown 2020. The catch is that the baseline is microscopic (half an aperture, millimeters at most), so the disparity is tiny and ambiguous, so learned priors do most of the work, and dual-pixel depth is a cue, not a laser range-finder.

fig-dual-pixel-split
Figure 34.1.2 (reproduced). A dual-pixel splits the photodiode in two under one shared microlens. Because the microlens images the lens's exit pupil onto the pixel, the left sub-diode collects rays from the right half of the aperture and the right sub-diode from the left half, so the two sub-diodes see the scene from slightly different viewpoints (a stereo pair of baseline ≈ half the aperture). In focus (top), the two sub-images coincide; out of focus (bottom), they shift apart by a phase whose sign and size give the defocus, the signal for phase-detection autofocus, and a faint per-pixel depth cue. Summed, the two halves reproduce an ordinary pixel with no light lost.

Recap: big lessons in this lecture

💡 Big lesson (L2.1) — light is a spectral distribution

Light, and the physical color it carries, is described by a spectral distribution: the power it carries at each wavelength, a function $S(\lambda)$. One wavelength is a single pure color; real light is a weighted mix of all of them. Everything downstream (how a prism fans light out, how a surface reflects it, how a sensor or an eye turns it into a perceived color) starts from this per-wavelength power.

fig-light-spectra
Figure 2.1.6 (reproduced). The spectra of real light sources. Each “white” source carries a different spectral power distribution $S(\lambda)$: daylight and tungsten are smooth Planck curves (cool and warm), a fluorescent tube adds sharp mercury lines on broad phosphor humps, a white LED is a blue spike feeding a yellow phosphor, and clear sky is daylight steepened by Rayleigh scattering. The swatch gives each source's perceived color; several read as nearly white despite very different spectra. Interactive: pick a source, or overlay them all; each spectrum also plays as a 1-D traveling wave, and a bandpass-filter slider isolates a band to show the surviving wave and its color: a narrow band gives a clean tone and a saturated hue, a wide band stays noisy and washes toward white.
💡 Big lesson (L2.4) — Snell's law

At a boundary between two media, light bends by $n_1\sin\theta_1 = n_2\sin\theta_2$, toward the normal entering a denser medium, away from it on the way out. This single rule is the seed of all lens optics: every focal length, every ray trace, the thin-lens equation, and every aberration is Snell's law applied at curved glass surfaces. Pair it with the fact that the index $n$ depends on wavelength (the next lesson) and you also get dispersion. Almost everything optical in this book traces back to it.

fig-reflection-refraction-diffraction
Figure 2.1.12 (reproduced). Three things light does at a surface. Reflection: a ray bounces off a smooth surface with the angle of reflection equal to the angle of incidence (θᵢ = θᵣ), both measured from the surface normal. Refraction: a ray crossing into a denser medium bends toward the normal because light slows down, obeying Snell's law n₁ sin θ₁ = n₂ sin θ₂; past the critical angle, a ray crossing into a rarer medium cannot escape at all and undergoes total internal reflection (a faint reflected ray is always present). Diffraction: a wave passing a small aperture or edge spreads instead of traveling straight, through an angle θ ≈ λ/d: the narrower the aperture relative to the wavelength, the wider the spread, which is why stopping a lens down too far softens rather than sharpens an image. Reflection and refraction are the everyday cases; diffraction returns in the final section.
💡 Big lesson (L2.5) — every material disperses

The refractive index is not a constant: $n(\lambda)$ depends on wavelength: in ordinary glass it rises toward the blue, so blue bends more than red. Because of this you cannot route every wavelength the same way with a single refraction: a prism fans white light into a spectrum, a raindrop makes a rainbow, and a simple lens focuses blue and red at slightly different distances: chromatic aberration. Much of the craft of lens design (combining crown and flint glass into achromatic and apochromatic groups) exists to fight this one fact. Dispersion is not a defect of cheap glass; it is built into how matter and light interact.

fig-prism-dispersion
Figure 2.1.15 (reproduced). Dispersion in a prism. Because the refractive index varies with wavelength (Cauchy's law: $n$ higher toward the blue), each color bends by a slightly different amount at each glass face, so a single white ray entering the prism fans out into a spectrum. This is just Snell's law applied wavelength-by-wavelength, the same physics behind the rainbow and behind chromatic aberration in lenses. Drag the incoming ray, or change the glass index and dispersion.