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
Titles jump to the section below; ↗ opens it in the book.
Light and optics⧉
Light: rays, waves, and the spectrum⧉
optionalThere 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.
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
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).
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).
Isaac Newton (1642–1727) needs little introduction, but the prism is only the start of his presence in this book. The spectrum he split from white light is the physical basis of all the color science to come, and his Opticks established that color lives in the light, not the object. His corpuscular view of light competed for a century with the wave picture: both, we now know, are needed. On the mathematics side we still run Newton's method (step by the inverse curvature, $H^{-1}\nabla f$) whenever a solver wants second-order convergence, and the Gauss–Newton refinement sits at the heart of feature tracking and bundle adjustment. Portrait: James Thornhill after Godfrey Kneller, 1689, public domain (via Wikimedia Commons).


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

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

A mirror plays no favorites among directions: it reverses only front-to-back, the one axis pointing into the glass, and treats left-right and up-down exactly alike. The famous swap is in the reading, not in the glass. To compare your reflection with yourself you mentally turn to face the way it faces, and because up and down are pinned by gravity (they are absolute) you turn about the vertical axis, which is the rotation that trades your left hand for your right. Left and right are defined relative to your own body and heading, so they are the pair a vertical turn exchanges; up and down, anchored to the world, stay put. Do the rotation the other way, lie down and turn about a horizontal axis, and the very same mirror now seems to flip up and down and leave left and right alone. Nothing changed but you: the asymmetry lives in our sense of direction, not in the physics of reflection.
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).
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:
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.

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.
The name illustrates Stigler's law of eponymy: no scientific discovery is named after its original discoverer. The relationship was found, lost, and re-found across fifteen centuries:
- Ptolemy (c. 150 AD) measured air-to-water and air-to-glass refraction carefully and tabulated it, but fit the data to a quadratic that only works for small angles. Close, but not the true law.
- Ibn Sahl (Baghdad, On Burning Instruments, 984 AD) had the correct law (stated as a constant ratio of lengths equivalent to the sine relation) and used it to design lenses that focus without aberration, more than six centuries before Europe. His was arguably the first true statement of refraction.
- Thomas Harriot (c. 1602) rediscovered the sine law experimentally in England but, as with much of his work, never published.
- Willebrord Snel van Royen (Snellius, 1621) derived it (in a cosecant form) in an unpublished manuscript found among his papers after his death: the source of the English name.
- René Descartes (Dioptrique, 1637) was the first to publish the law in its modern sine form, $n_1\sin\theta_1 = n_2\sin\theta_2$, alongside a (physically dubious) mechanical derivation. This is why the French still call it la loi de Descartes.
- Pierre de Fermat (1657–62), distrusting Descartes' reasoning, re-derived the same law from his principle of least time, the standard variational argument still taught today, and the one that ties back to the equal-optical-path view of why a lens focuses.
So the law that anchors this entire book is named after the man who left it in a drawer, was first written down correctly by Ibn Sahl, and was given its cleanest reason by Fermat. A fitting reminder that the tidy attributions in textbooks are usually a courtesy, not a history.
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.

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.

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.

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.
Light-matter interaction is largely resonance⧉
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.
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.

Both follow from Rayleigh scattering: air molecules are much smaller than the wavelength of light and scatter short (blue) wavelengths far more strongly than long (red) ones: the scattered fraction grows as $1/\lambda^4$, so blue (≈450 nm) scatters roughly ten times more than red (≈650 nm). At midday the sunlight takes a short path through the atmosphere; the blue it sheds is scattered out in every direction and reaches your eye from all over the sky, so the sky reads blue while the sun stays roughly white. At sunset the light skims a long, grazing path through the air; by the time it reaches you almost all its blue has been scattered away, and mostly orange and red survive, so the sun and the clouds near it redden (Figure 2.1.19). When the scattering particles are large compared to the wavelength (water droplets in fog or cloud), every wavelength scatters about equally (Mie scattering), which is why clouds and haze are white or gray, not blue. Minnaert, The Nature of Light and Color in the Open Air One caveat the physics alone hides: the color you finally see is not in the scattered light by itself: "blue" and "orange" are your cones' verdict on these spectra, so the apparent color of the sky depends on the visual system reading it as much as on the scattering. The same sky spectrum read by a different eye is a different color, vividly so across species (→ the cross-species sky figure in Chapter 3.2, Perceptual color and trichromatic vision Weiss & Springer 2026 (color of the sky for a non-human)).

A rainbow is a caustic, a place where rays concentrate. It is tempting to explain it as "dispersion, like Newton's prism," but dispersion alone is not a rainbow: a prism merely fans white light into a spread, and a spread is not a bright arc pinned at a fixed angle. The brightness and the fixed 42° angle come from the geometry of the sphere; dispersion only supplies the colors. Each falling raindrop is a tiny sphere, and sunlight refracts in, reflects once off the back, and refracts out again (Figure 2.1.21, left).
Slide the entry point across the drop (the impact parameter) and the total deviation of the exiting ray sweeps down to a minimum (about 138° for water) and turns back up. Near that minimum the deviation is stationary, so rays entering at many different points all leave in almost the same direction: they bunch up, and that pile-up is the bright arc, seen at $180°-138° \approx$ 42° from the antisolar point (Figure 2.1.21, right). This is why the single internal reflection is essential, and why a ray that only refracts in and out, with no bounce, makes no rainbow at all: with two refractions only, the deviation grows monotonically with the impact parameter and never turns around, so there is no stationary angle for light to concentrate at. The primary bow is the one-bounce caustic at 42°; the fainter, color-reversed secondary bow is the two-bounce caustic, its own minimum putting it at about 51°. Dispersion then sets the color order: because $n$ is a touch larger toward the blue, each color's caustic sits a degree or so from its neighbors, fanning the bunched light into the ordered band we see.
Between the two bows sits a conspicuously darker strip of sky, Alexander's band (named for Alexander of Aphrodisias, who described it around 200 AD). Its darkness follows directly from the caustic story: one-reflection light only ever emerges at 42° or less (it piles up at 42° and scatters out to fill the sky inside the primary bow), while two-reflection light only emerges at 51° or more, outside the secondary. The 42°–51° gap between them receives almost no rainbow light from either path, so it reads as a dark band, with brighter sky on both sides. You can see the whole story in a real double bow over Loch Ness (Figure 2.1.24): bright primary, fainter reversed secondary outside it, the dark band between, and the noticeably brighter sky inside the primary.
You can run the whole experiment on a workbench with a clear glass sphere standing in for a raindrop (Figure 2.1.22): a bright beam refracts in, reflects off the back, and throws a little rainbow caustic onto a card. Send narrow laser beams through the same sphere in a hazy room and the rays themselves become visible (Figure 2.1.23): you can watch each beam refract in, bounce off the back, and refract out: the exact refract–reflect–refract path the diagram traces. The rainbow in the sky is just this single-drop geometry, summed over a skyful of drops. Minnaert, The Nature of Light and Color in the Open Air

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⧉
optionalUse 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.
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⧉
optionalCamera 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.
Fourier⧉
MTF: a lens's frequency response⧉
optionalFor an incoherent, locally shift-invariant imaging system, let $g$ be the intensity PSF. Its Fourier transform is the optical transfer function (OTF), which may be complex. The modulation transfer function is its normalized magnitude:
It measures contrast transfer but omits phase shifts. An ideal finite-aperture lens is still diffraction-limited: its MTF falls with frequency and reaches a cutoff. Only an ideal impulse PSF would retain unit contrast at every frequency. Lens MTF can vary across the field and with orientation. See Chapter 22.1, Aberrations and optical challenges.
Aberrations and optical challenges⧉
Radial distortion⧉
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
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,
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.

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

Flare and coating⧉
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.
You can watch the ghosts form by tracing a single ray through a real lens (Figure 22.1.14).

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.


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⧉
optionalEverything 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.
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,
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
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.
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⧉
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
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,
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.

Aberration data in the DNG, and the limits of per-copy correction⧉
optionalThe 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⧉
After cataloging lens defects, the next step might seem to be correction. But correction and optimization both need measurements first. The optimizer of the next chapter minimizes a number; the deconvolution of Aberrations correction inverts a measured blur; the manufacturer who sells you the lens quotes a spec; and the reviewer who pans it backs the verdict with a chart. Every one of those is a measurement. So this chapter is the assessment step that the rest of the part stands on: how do you turn "this lens is a bit soft in the corners and fringes in blue" into numbers you can optimize against, invert, advertise, or argue about? You cannot improve, target, or correct what you have not quantified: that is the whole reason this chapter comes before Lens optimization.
One measurement dominates, and we have already met the underlying machinery. Locally, a linear incoherent imaging system blurs approximately by convolution with its point-spread function; convolution is multiplication in the Fourier domain. The frequency-domain face of the lens's blur is its transfer function, and its magnitude, which tells you how much contrast survives at each spatial frequency, is the Modulation Transfer Function, the main metric of this chapter. Everything else (spot size, distortion, vignetting, color shift) is a companion measurement that the MTF either contains or sits beside.
The modulation transfer function (MTF)⧉
Imagine photographing not a sharp edge or a point but a smooth sinusoidal intensity pattern: bright and dark stripes whose brightness varies as a sine wave at a single spatial frequency $\nu$, measured in line-pairs per millimeter (lp/mm) at the image plane. A perfect lens would reproduce that sinusoid with its full contrast intact. A real lens, because it spreads each point into a small blob, smears adjacent bright and dark stripes into each other and the reproduced sinusoid comes out with less contrast: the peaks lower, the troughs higher. Define the modulation of a pattern as $(I_\text{max}-I_\text{min})/(I_\text{max}+I_\text{min})$, and the MTF at frequency $\nu$ is simply the ratio of output modulation to input modulation:
Plot that ratio against $\nu$ and you get the curve familiar from lens reviews (Figure 22.3.1). It starts at $1.0$ at zero frequency (the transfer is normalized by its zero-frequency response; a uniform field itself has no sinusoidal contrast) and generally falls toward $0$ at fine frequencies, though lobes and zeros can interrupt a monotonic decline, because the finest stripes are blurred into a flat gray. Coarse detail (low $\nu$) survives well; fine detail (high $\nu$) is attenuated; somewhere the lens simply stops resolving. The MTF is the single most-used summary of what "sharpness" means, and the rest of this chapter is, in one way or another, ways to obtain it and things to plot it against.
The OTF/PSF relationship. The MTF is not separate from the blur studied in the deblurring chapters. It is that blur, viewed in the frequency domain. The lens's full frequency response is the Optical Transfer Function (OTF), and the OTF is exactly the Fourier transform of the point-spread function:
The MTF is the magnitude of the OTF; the discarded phase part is the Phase Transfer Function (PTF), which retains phase shifts lost from the magnitude alone. Coma can affect both magnitude and phase; the MTF alone cannot distinguish a PSF from its mirror image. This is the same convolution-theorem duality the book keeps returning to: blurring an image is convolving by the PSF in space, which is multiplying by the OTF in frequency. The image is $\text{scene} * \text{PSF}$, and Aberrations correction's deconvolution divides by the OTF, so the MTF is literally the thing whose zeros bound what deconvolution can recover (you cannot divide back contrast the lens drove to zero). PSF and complex OTF are equivalent descriptions, while MTF discards phase; this chapter mostly works in the frequency domain because that is where "sharpness vs. detail size" reads off most cleanly.
Scalar summaries: MTF50 and limiting resolution. A whole curve is more than people want when they are ranking lenses, so the curve gets collapsed to a number or two. A common scalar is MTF50, the spatial frequency at which the MTF has fallen to $0.5$, i.e. where the lens still passes half the contrast. It is popular because it correlates well with perceived crispness: a lens with a higher MTF50 usually looks sharper. A second common scalar is the limiting resolution, the frequency at which the MTF drops to some small cutoff (say $0.1$, or the noise floor), the finest line-pairs/mm the lens still resolves at all. The two answer different questions: MTF50 is about how punchy the mid-frequencies look, limiting resolution about the absolute finest detail present.
The diffraction ceiling. For a fixed pupil amplitude and support in incoherent imaging, removing wavefront aberration gives the diffraction-limited MTF bound, because diffraction is a floor on the PSF that no amount of design removes (FUNDAMENTALS). For a circular pupil the diffraction-limited MTF falls to zero at the cutoff frequency
with $\lambda$ the wavelength and $N$ the image-side f-number in the paraxial air model (use the effective value at finite magnification): beyond $\nu_c$ a perfect lens passes nothing. Stopping down (raising $N$) lowers $\nu_c$, which is the frequency-domain statement of the familiar fact that small apertures soften everything by diffraction. So the diffraction curve is the ceiling in Figure 22.3.1, and a real lens's MTF lives somewhere underneath it, pushed down further by every aberration the previous chapter named.
MTFs multiply. One last fact makes the MTF the right representation for a photographic system, not just a lens. The sensor blurs (finite pixels, the anti-aliasing filter), the demosaic blurs, motion blurs, and the lens blurs, and for linear, shift-invariant stages their transfer functions multiply:
This is why a superb lens on a coarse sensor still looks soft (the sensor's MTF caps the product), and why "system MTF" (lens and sensor and pipeline together) is what photography actually cares about. Adaptive denoising, nonlinear demosaicking, sharpening, and sampling can violate this simple factorization. A measured system response then depends on the target and settings, rather than being one universal product.
Measuring MTF in practice⧉
optionalSo far the MTF is a definition. How do you actually obtain it from a lens on a bench? There are two families of method, and the second one is the workhorse of modern testing.
Direct: sinusoidal and Siemens-star targets. The literal approach is to photograph the very thing the definition describes (a chart of sinusoidal patterns at a ladder of known frequencies) and read the output modulation off each, frequency by frequency. It is conceptually pure but fussy: you need an accurate sinusoidal target, careful exposure, and one patch per frequency. A neat refinement is the Siemens star, a radial pattern, sinusoidally modulated for direct MTF measurement or formed from binary wedges for a simpler resolution check, whose spatial frequency rises smoothly toward the center; a single star sweeps a whole range of frequencies in one shot, and the radius at which its spokes blur into gray reads off the limiting resolution. These methods give trustworthy MTF numbers and are still used for careful lab work.
The slanted-edge (SFR) method: ISO 12233. The method that took over, because it needs only one frame of one edge, is the slanted-edge or spatial-frequency-response (SFR) technique standardized as ISO 12233. Photograph a sharp black-to-white edge tilted a few degrees off vertical. The slant provides subpixel sampling: because the edge is slanted, each successive row of pixels crosses it at a slightly different sub-pixel position, so the rows together sample the edge profile at a much finer spacing than the pixel pitch. Pooling all the rows (projecting each pixel onto the axis perpendicular to the edge and binning) yields a super-resolved profile of the edge: the edge-spread function (ESF), what the lens-plus-sensor does to an ideal step. The slant yields finer sampling than the pixel pitch alone.
From the ESF the rest is mechanical (Figure 22.3.2). Differentiate the ESF and you get the line-spread function (LSF), the response to a thin line rather than an edge, which is the two-dimensional PSF integrated along the edge direction. Fourier-transform the LSF and take the magnitude, normalized so the zero-frequency value is $1$, and you have the MTF (in this context usually called the SFR). The compact chain below omits the DC normalization; implementations also linearize pixel values, window the LSF, and compensate the numerical derivative. Avoid clipped edges and document processing. The chain is the whole method in one line:
This method is cheap, repeatable, and automatable. Open implementations (Burns's sfrmat, the open-source MTF Mapper) read the chart and spit out curves, which is one reason camera reviews and QA lines rely on it. Crucially, it measures the whole system: lens, sensor, anti-aliasing filter, demosaic, and any ISP sharpening, all folded into one curve (the product of MTFs from the previous section). For photography that is useful: it is the sharpness you will actually get, though it means you must hold the sensor and processing fixed if you want to compare lenses.
Where, and in which direction. A single curve hides the fact that the MTF is not one number even for one lens at one aperture: it varies across the field and with the orientation of the detail, so a real measurement is a small matrix of curves. Across the field, a lens is nearly always sharpest on the optical axis and softer toward the corners (aberrations grow with field angle), so the bench measures the MTF at several image heights (center, mid-frame, and corner) not just on-axis. Orientation matters because at any off-axis point two special directions behave differently: sagittal structures, oriented radially (spoke-like, pointing at the frame center), and meridional (also called tangential) structures, oriented across the radius (concentric, rim-like). Off-axis astigmatism (Chapter 22.1, Aberrations and optical challenges) brings these two orientations to focus at slightly different distances, so the lens resolves one better than the other and their MTF curves separate; on-axis, by symmetry, the two coincide. This is exactly what a manufacturer's MTF chart shows (Figure 22.3.3): contrast plotted against image height, with often a solid curve for sagittal and a dashed curve for meridional (check the legend and whether the curves are measured or calculated), usually at two frequencies: a low one (around 10 lp/mm) that reads as contrast and "character," and a higher one (around 30 lp/mm) that reads as fine-detail sharpness. Do not confuse the orientation of test lines with the perpendicular direction in which their intensity varies. Manufacturers and measurement programs can use different sagittal/tangential labeling conventions. Once you know the conventions, the chart is easy to read: curves that stay high and flat mean even sharpness to the edge; a large sagittal–meridional gap indicates directional differences that can arise from astigmatism, coma, and other effects; both falling together means plain corner softness; and a low-frequency curve that sags signals veiling flare or low micro-contrast rather than lost resolution.
Spot diagrams and the PSF⧉
optionalThe MTF lives in the frequency domain; its space-domain twin is the point-spread function and, for a designer working from a ray model, the spot diagram. As Lens optimization develops in detail, you can estimate the PSF geometrically by tracing a fan of rays from one field point through the lens and scattering their landing points on the image plane (Figure 22.4.1). A tight cluster means the lens brings that point nearly to a point (sharp; a smeared blob means it does not) and, as the previous chapter showed, the shape of the blob diagnoses which aberration dominates (a round haze is spherical, a one-sided comet is coma, an ellipse is astigmatism).
For measurement purposes the spot diagram hands us a scalar (the RMS spot radius, the root-mean-square spread of the landing points) which is the classical sharpness metric the merit function of the next chapter shrinks. And experimentally, rather than tracing rays, you can simply image a point source (a pinhole or a distant star) through the real lens and photograph its PSF directly. That measured PSF is precisely what Aberrations correction feeds to deconvolution. So the same lens quality appears in three forms: as a measured PSF (image of a point), as a ray-traced spot diagram (the design's prediction), and as an MTF (the magnitude of the Fourier transform of a normalized PSF). A ray spot diagram omits diffraction and needs appropriate ray weights to approximate an intensity PSF. It is useful when geometric blur dominates; it is not interchangeable with a measured diffraction-inclusive PSF near the diffraction limit.
MTF through focus and depth of focus⧉
optionalEverything above measured the MTF at the best focus. But focus is itself an adjustment, and asking how the MTF behaves as you change focus answers a different and very practical question. Fix a single spatial frequency, then slide the sensor (or refocus the lens) and re-measure the MTF at each position. The contrast rises to a peak at best focus and falls away on either side: the through-focus MTF (Figure 22.3.4). The position of the peak is best focus; the width of the peak is the depth of focus: the range of sensor positions over which that frequency stays above a usable contrast. (Depth of focus is the image-side cousin of the FUNDAMENTALS depth of field on the subject side; they are linked by magnification.)
Two features make this measurement diagnostic. First, higher spatial frequencies give narrower through-focus peaks: fine detail demands more precise focus than coarse detail, so the depth of focus shrinks with the detail you ask for: a low-frequency target tolerates sloppy focus, a high-frequency one does not. Second, if the through-focus peaks for different frequencies (or for different field points, or different colors) sit at different focus positions, that offset is a signature of residual aberration: spherical aberration shifts best focus with frequency, field curvature shifts it with field, axial chromatic aberration shifts it with color (the next section). A perfectly corrected lens would have all its peaks aligned; the offsets reveal the residual aberrations.
Field-dependent MTF: sagittal vs tangential⧉
optionalA lens is sharp in the center and softer toward the corner, so a single MTF number for "the lens" hides where it is good and where it gives up. The standard published chart therefore plots the MTF against image height (distance from the optical center, in millimeters, from $0$ at the center out to the corner) at a coarse frequency (say $10$ lp/mm, which tracks contrast and "punch") and a fine frequency (say $30$ lp/mm, which tracks fine resolution). And each of those is split again into two curves, because off-axis a lens treats two orientations of detail differently: sagittal detail (lines running radially, toward the center) and tangential detail (lines running across the radius, azimuthally) focus differently. So the manufacturer chart is four curves (sagittal and tangential at each of two frequencies) plotted center to corner (Figure 22.3.5).
Reading the chart is straightforward once you know what the curves mean. Both curves falling toward the corner is the ordinary off-axis softening, as coma, field curvature, and lateral color pile up where the previous chapter said they would. The more telling feature is the gap between the sagittal and tangential curves: that gap can indicate astigmatism or other directional aberrations. Through-focus measurements can reveal whether radial and tangential detail reach best focus on different planes; when they do, one sensor plane cannot render both at their sharpest. A lens whose four curves stay high and together across the whole frame is "even"; one whose corners collapse, or whose sagittal and tangential curves split wide apart off-axis, is dumping quality into the edges, exactly the compromise Lens optimization will show being negotiated, and exactly the corner softness Aberrations correction may be asked to claw back.
Color, geometry, and illumination measurements⧉
optionalThe MTF and its through-focus and field variants quantify blur. But the previous chapter's catalog had defects that are not blur at all (color misregistration, displaced geometry, darkened corners) and each has its own measurement, which (not coincidentally) is exactly the data the lens-profile correction of Aberrations correction needs.
Lateral (transverse) chromatic aberration is a difference in magnification between color channels, so it is measured as a per-channel radial scale: image a high-contrast target, find where the red, green, and blue edges land as a function of field, and fit the tiny scale factor that separates them. It comes out as one magnification offset per channel, which is precisely the per-channel radial rescale the ISP plays back to collapse the colored fringe.
Longitudinal (axial) chromatic aberration is instead a difference in focus depth between colors, so it is measured through focus: find the best-focus sensor position for red, green, and blue separately, and the spread between them is the axial color. It is the through-focus measurement of the previous section, repeated per wavelength, and it is what achromat and apochromat design (and, partially, deconvolution) aim to flatten.
Geometric distortion is measured by imaging a ruled grid and quantifying how far the imaged lines bow from straight, then fitting the Brown–Conrady coefficients $k_1, k_2, \dots$ (or the division-model $\lambda$) defined in the challenges chapter; the result is reported as a percent distortion versus field. Those fitted numbers are exactly the coefficients the radial-warp correction inverts.
Vignetting / relative illumination is measured by photographing a uniform field and recording the radial brightness falloff: corner brightness relative to center, in stops or percent. A single uniform-field image measures their combined effect, including sensor angular response; it does not separate the mechanisms by itself. Aperture-dependent measurements and a model can help isolate optical clipping. The calibrated combined response supplies the gain map used to even the frame.
Field curvature is measured by mapping best-focus depth versus field: the surface on which the image is actually sharp is not the flat sensor but a curved (Petzval) surface, and tracing that surface predicts how soft the corners go when the center is nailed. It is the spatial bookkeeping behind why "flat-field" designs are prized.
Each of these is a small, targeted measurement, and each one's output is the input to a correction in the next chapters: the clean illustration of why measurement has to come first.
Scalar quality summaries⧉
optionalFinally, the field wants a single number to rank lenses and to hand an optimizer, so the rich curves above get collapsed, at a cost. The common scalars are the ones we have already met: MTF50 and limiting resolution (lp/mm) from the MTF curve, RMS spot radius from the spot diagram, and the wavefront-error metrics: RMS wavefront error and its companions the Strehl ratio (peak intensity of the real PSF relative to the diffraction-limited one) and the Maréchal criterion (a lens is "diffraction-limited" if its RMS wavefront error is below about $\lambda/14$). Some summaries go further and weight the MTF by the human contrast-sensitivity function to predict perceived sharpness: the family of "blur index" or acutance scores (SQF and its relatives).
The plain caveat is that every one of these is a lossy summary of a much larger object: a fuller description includes MTF and phase over frequency, field, focus, and color, together with transmission, distortion, flare, and other properties, effectively a hypercube, and any single number throws most of it away. A scalar is genuinely useful for ranking lenses and, especially, as an optimization target the next chapter can drive down; but it hides where in the frame, at what detail size, and in what color the lens is good or bad. That is the right note to end on, because it is the seam to the rest of the part: this chapter produces the scorecard, Lens optimization compresses it into a merit function and minimizes it, and Aberrations correction takes the measured PSF, distortion, vignetting, and color maps and inverts them. Measurement first; then you optimize, and then you correct what optimization left behind.
Lens optimization⧉
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⧉
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:
- each surface's radius of curvature, the dominant knob, since curvature is what bends rays;
- the glass of each element, which fixes both its refractive index $n$ and its dispersion (how strongly $n$ varies with wavelength). This variable is special: glass comes from a catalog of a few hundred named types, so it is a discrete choice rather than a continuous variable, an awkward variable for a gradient-based optimizer, and one reason global search (below) earns its keep;
- the thicknesses of the elements and the air-gap spacings between them;
- aspheric coefficients, when a surface is allowed to depart from a sphere (an extra handful of knobs per aspheric surface: Aberrations explains why one asphere can do the work of several spherical elements);
- the stop, the size and axial position of the aperture, which sets the f-number and selects which rays even participate.
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,
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:
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⧉
optionalThe 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,
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.

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⧉
optionalThis 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⧉
optionalIf 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:
- Speed (low f-number) vs. aberration control. A faster lens opens the aperture wider, which means rays through the edge of the pupil, exactly the rays where spherical aberration, coma, and chromatic error are worst (the cubic term grows with aperture). Every stop of extra speed multiplies the aberrations the merit function has to fight, demanding more elements or exotic glass to hold sharpness. This is why an $f/1.2$ prime is large, heavy, and expensive while an $f/4$ lens of the same focal length is small and cheap.
- Size and weight vs. correction. More correction generally means more elements and longer paths; a pocketable lens has a tight glass budget, so its merit function is minimized under a hard size constraint, and quality is the thing that gives.
- Cost vs. sharpness. Sharpness is bought with element count, special low-dispersion glasses, and aspheric surfaces, each of which costs money to specify, source, grind or mold, and assemble. A cheaper lens is a lens told to hit its quality target with fewer and plainer ingredients.
- Zoom range vs. everything. A zoom must keep all of the above acceptable not at one focal length but across its whole range simultaneously, with groups sliding between configurations. Extending the range generally adds competing design conditions, which is why a wide-range superzoom is the hardest thing in the catalog to optimize and the most visibly compromised.
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.
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⧉
optionalEverything 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.
Focus⧉
Focus mechanics⧉
optionalStart 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.
How far must the lens move? Write subject closeness as $D=1/u$, in inverse meters. The thin-lens equation gives
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.
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⧉
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.
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)⧉
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.

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
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.
The sub-mirror PDAF module just described is the single-lens reflex's signature trick, and also the reason the reflex design is being retired. The mirror earned its place with two historical advantages: it let the photographer view through the lens optically, and it fed a dedicated, fast phase-detection module. Both advantages are now shrinking. Electronic viewfinders have become good enough (and are needed for video regardless) and on-sensor phase detection (next section) has nearly closed the autofocus gap. The mirror's costs, meanwhile, have not shrunk. It adds moving parts and the per-body, per-lens front/back-focus calibration noted above; it enlarges the body; it imposes the retrofocus tax on wide-angle and large-aperture lenses by forbidding glass near the sensor (cross-ref A short bestiary of classic designs: the mirror box is exactly the standoff a retrofocus design must buy); and, most telling for this book, it occludes the imaging sensor while you focus, so the camera cannot run scene analysis (face and eye detection, subject recognition) on the actual image before the shutter fires. For video the mirror must stay up the whole time, forfeiting every one of its advantages at once. A design whose benefits are met elsewhere and whose costs are paid in size, complexity, lens freedom, and the very sensor access that computational photography depends on is a design on the way out: the reflex camera is yielding to mirrorless, and the autofocus story is migrating wholesale onto the main sensor. (This synthesis follows the author's 2018 essay "The DSLR will probably die", Sources/Blog/the-dslr-will-probably-die-are-mirrorless-the-future-of-large-standalone-cameras.md, Blog Index.)
On-sensor PDAF and dual-pixel AF⧉
optionalPhase 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).
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⧉
optionalAutofocus 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.
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⧉
optionalEverything 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⧉
optionalStart 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,
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
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)
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
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⧉
optionalThe 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:
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:
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)
The single most consequential trick in this chapter has a tangled history, a case study in how an industrial secret escapes. The vacuum-deposited quarter-wave coating was invented in 1935 by Alexander Smakula, a Ukrainian-born physicist at Carl Zeiss in Jena (German patent DE 685767, "a method for increasing the light transmittance of optical parts"). Zeiss and the German military grasped at once what it was worth (a coated gunsight or pair of binoculars gathers more light and, just as important, throws fewer tell-tale reflections back at the enemy) and the invention was promptly classified. The patent was withheld from publication until 1944, and through the late 1930s Zeiss ran more than a dozen coating chambers whose output went only to military optics, stamped with a small red "T" (for Transparenz, transmission, the ancestor of today's T\* multicoating).
It was never, however, a uniquely German idea. John Strong at Caltech published an independent re-invention in 1936 (he evaporated a fluoride film onto a Leica's lenses, probably the first coated camera lens outside Germany) and Cartwright and Turner at MIT were coating optics by 1938; Katharine Blodgett at General Electric demonstrated a different (and fragile) anti-reflection film the same year. So when World War II ended, two things happened at once. First, the patent monopoly evaporated: among the spoils of victory, Allied teams seized and microfilmed some 145,000 German patent files, and the U.S. Office of Alien Property vested tens of thousands of German patents (the 1946 London Agreement on German-owned patents formalized the principle) so that German optical know-how, coatings included, became freely available to Allied industry with no royalty owed. Second, Zeiss itself was torn in two: as the war closed, American forces evacuated roughly a hundred senior Zeiss scientists and managers westward from Jena to Oberkochen in the U.S. zone, days before the Soviets took Thuringia and dismantled most of the Jena works as reparations. For the next four decades a Western Zeiss (Oberkochen) and an Eastern VEB Carl Zeiss Jena both claimed the name, fighting a trademark war settled only in 1971 and ended only by German reunification in 1991. The lesson for the history of optics is the plain one: the coating spread across the world not because a single patent fell, but because the idea had already been discovered in the open more than once: the war merely made certain of it.
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)
Computational deflare and glare deconvolution⧉
optionalHardware 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)
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.
Optical stabilization⧉
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⧉
optionalStart 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
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.
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)⧉
optionalTo 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).
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)
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⧉
optionalOptical 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).
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⧉
optionalThe 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.
Recap: big lessons in this lecture
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.

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.

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.
