BookNotesSlidesP-sets Syllabusdraft · v0.2.49.1
💬Comments welcome. To leave a note, select any text and click the note / highlight button that pops up — or open the panel with the tab at the top-right (‹). Notes are visible only inside our private review group.
Computational Photography, an AI-powered Slopendium — 23 Depth of field
expand to📖 Full book outline1 parts · 3 chapters · 15 sections · 15 figures embedded · 3 placeholders · double-click a figure to enlarge
▸Part 23 DEPTH OF FIELD⧉
<!--uid: depth-of-field-part-->
▸23.1 Bokeh, focus stacking, and depth-of-field control⧉
fig-dof-coc
fig-dof-coc · depth of field via the circle of confusion: the double cone behind the lens; points whose blur disk stays within the CoC limit c at the sensor are "acceptably sharp" → near/far DoF limits; CoC + hyperfocal H=f²/(N·c) labeled ✅
fig-dof-raydiagram
fig-dof-raydiagram · **interactive** 2-D thin-lens depth-of-field ray diagram + plot: set focal length, f-number, subject distance, circle of confusion and sensor size; the diagram shows the focused cone landing on the sensor and a background point spreading into a blur disk; reads off near/far limits, hyperfocal distance H and magnification; "constant magnification" toggle plots total DoF vs focal length (nearly flat — at fixed framing DoF barely depends on focal length). A lighter companion to the 3-D dof sim. ✅
⬜ figure not yet created
pointer to FUNDAMENTALS for the full geometry)
fig-bokeh-shapes
fig-bokeh-shapes · bokeh: out-of-focus highlights take the aperture's shape — circular (many blades / wide open) vs polygonal (few blades, stopped down); synthetic defocus-disk fields + aperture insets ✅
fig-cats-eye-vignetting
fig-cats-eye-vignetting · cat's-eye bokeh: off-axis defocus disks clipped into lemon / cat's-eye shapes by optical (mechanical) vignetting toward the frame edge; round at center → clipped at edge, tilted toward center ✅
fig-focus-stacking
fig-focus-stacking · optics-chapter illustrative figure (07-07 Figure 4): a stepped-focus stack → sharpness selection → all-in-focus composite. Synthetic per-slice defocus on one photo (`sourced/corn-cobs.jpg`, © Frédo Durand) — license-safe. The full real-data treatment lives in part-08 `fig-focalstack-*` ✅
equations
**all imported** from FUNDAMENTALS (circle of confusion, hyperfocal $H=f^2/(Nc)$, near/far limits, DoF scaling). New here: aperture-shape ⇒ defocus-disk shape (the disk is the **image of the aperture stop**)
cat's-eye area loss from off-axis pupil clipping.
23.1.1 The geometry of focus⧉
▸23.2 Fake (synthetic) depth of field⧉
fig-portrait-mode-pipeline
fig-portrait-mode-pipeline · fake/portrait-mode DoF pipeline (9.8): all-sharp input → depth/subject map → depth-aware aperture-disk background blur → sharp subject composited on top ✅
fig-gaussian-vs-bokeh
fig-gaussian-vs-bokeh · the same defocused background two ways — a flat Gaussian (dim, shapeless) vs a real aperture-disk bokeh where clipped highlights bloom into hard-edged disks (blurred in linear light); fake vs convincing ✅
fig-occlusion-aware-blur
fig-occlusion-aware-blur · defocus is not a 2-D convolution — naive whole-image blur bleeds a sharp foreground edge into the background (a halo), vs occlusion-aware rendering that blurs the background up to the subject's silhouette and keeps the subject crisp ✅
fig-portrait-failure-modes
fig-portrait-failure-modes · a 2×2 gallery of the tells of fake DoF — matting halo (hair), wrong subject blurred, flat shapeless blur, foreground bleed ✅
equations
the **thin-lens blur radius** vs depth — for a pixel at depth $z$ with focal plane at $z_f$, the circle-of-confusion (hence blur-kernel) radius $c(z)\propto \big|\tfrac{1}{z_f}-\tfrac{1}{z}\big|$ (imported from [[Bokeh, focus stacking, and depth-of-field control|depth of field]] / FUNDAMENTALS)
**energy-correct scatter** — each source pixel splats a disk of total weight 1, so brightness is preserved and clipped highlights bloom.
▸23.3 Focal stacks and depth of field extension⧉
⬜ figure not yet created
`fig-focalstack-problem` (a macro/close-up scene at one aperture: only a thin slab is sharp, foreground and background mush — "even f/16 isn't enough") fig-focalstack-problem
fig-focalstack-capture
fig-focalstack-capture · a focus stack — several frames of one scene focused at different distances, the sharp slab moving through depth — plus an inset on refocusing the lens vs translating on a rail 🟨
fig-focalstack-sharpness
fig-focalstack-sharpness · one frame walked through high-pass → square → smooth to produce its per-pixel sharpness map $s_k$ (pipeline layout with arrows + $\LaTeX$ labels) ✅
fig-focalstack-why-square
fig-focalstack-why-square · a 1-D edge whose signed band-pass averages to ~0, and how squaring it makes the local average register the presence of detail 🟨
fig-focalstack-argmax-composite
fig-focalstack-argmax-composite · the per-pixel argmax selection map (which-frame-won / coarse depth) beside the all-in-focus image, plus a zoom comparing $\gamma=1$ vs $\gamma=4$ weighting ✅
⬜ figure not yet created
exponent-1 vs exponent-4 weighting)
fig-focalstack-photomontage
fig-focalstack-photomontage · a weighted-sum merge (ghosting and blur at depth edges) vs a graph-cut-plus-Poisson merge (clean seams) of the same focal stack (Agarwala et al.) 🟨
fig-focalstack-magnification
fig-focalstack-magnification · a focus-at-infinity frame overlaid with a focus-close frame to show that refocusing changes scale, so frames must be registered before merging 🟨
💡 **Big lesson (L11.2 · Capture the full set, decide later):** instead of committing the focus distance at the instant of exposure, **record a whole stack of focal planes and choose per pixel afterward**. The slogan: *focus stacking is to the focus distance what HDR bracketing is to exposure and what the light-field camera is to the aperture* — defer an irreversible capture decision out of the moment of exposure, paying with **more data** and a **harder reconstruction (a per-pixel merge)** for the payoff of an all-in-focus image no single shot could make. (Registered in [[Big Lessons]] as **L11.2**; its full first-appearance box sits at the light-field / plenoptic introduction — here it recurs on the **focus axis**, the third sibling after HDR's **exposure axis** and panorama's **viewpoint axis**.)
equations
per-pixel **sharpness** $s_k(p)=\sum_{q\in w(p)} \lVert \nabla I_k(q)\rVert^2$ (local **high-frequency energy** — squared band-pass / Laplacian power, then window-summed/Gaussian-smoothed)
**all-in-focus selection** $k^\*(p)=\arg\max_k s_k(p)$, output $I(p)=I_{k^\*(p)}(p)$
**soft weighted composite** $I(p)=\dfrac{\sum_k w_k(p)\,I_k(p)}{\sum_k w_k(p)}$ with $w_k(p)=s_k(p)^\gamma$ (exponent $\gamma\!\approx\!4$ → near-argmax but smoother)
**Photomontage energy** $E(\ell)=\sum_p D_p(\ell_p)+\sum_{p\sim q}V_{pq}(\ell_p,\ell_q)$ minimized by graph cut (data $D$ = $-$sharpness of label $\ell_p$
smoothness $V$ = seam-cost penalizing visible transitions), then **Poisson** reconstruction across the chosen labels.