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.

20.4 Bells and whistles⧉

A long panorama exposes errors that a two-image stitch can hide: accumulated alignment drift, lens distortion, inconsistent brightness and moving content. Use overlap constraints across the image set, then choose a projection and source masks appropriate to the scene.

Keeping the source frames lets the final projection, crop and moving-object selection remain editable (L13.1).

The shift from a chain of pairwise estimates to a solve over the overlap graph is useful beyond panoramas. Structure-from-motion and simultaneous localization and mapping also use repeated observations to constrain a camera trajectory globally. A loop supplies information that a purely forward chain cannot use: the view at the end must agree with a view seen earlier.

20.4.1 Other projections⧉

A panorama can span far more of the world than a single flat image plane can hold, which forces a question the two-image demo never had to ask: onto what surface do you unroll the mosaic? The frames have already been registered to one another by the homographies; choosing a projection is a separate, later step, a re-parameterization of the output canvas, independent of the alignment. But it is not a cosmetic choice. The surface you pick decides what looks natural and what distorts, and there is a hard geometric tradeoff that no cleverness escapes.

Planar, or rectilinear, projection keeps scene lines straight under the central-camera model. It can approach but not reach a 180-degree field of view in a finite image; stretching becomes severe well before that. A 120-degree limit is a practical preference, not a mathematical cutoff.

Cylindrical projection can cover a full horizontal turn. With a level vertical axis, vertical scene lines and the horizon remain straight, while many other lines curve. Output scale is a rendering choice; calibrated intrinsics are needed to convert source pixels into rays.

An equirectangular image stores longitude and latitude on a rectangular grid, commonly covering 360 by 180 degrees in a 2:1 image. It is one representation of spherical directions; cube maps are another. The poles have singular coordinates and increasing area distortion. An interactive viewer resamples these directions into a perspective viewport, where correctly reconstructed straight scene lines remain straight.

For a camera ray $d=(d_x,d_y,d_z)$ with vertical axis $y$, define

$$\theta=\operatorname{atan2}(d_x,d_z),\qquad\phi=\operatorname{atan2}(d_y,\sqrt{d_x^2+d_z^2}).$$

Equirectangular coordinates are proportional to $(\theta,\phi)$, while cylindrical coordinates are proportional to $(\theta,d_y/\sqrt{d_x^2+d_z^2})$. Choose pixel scale, origin and vertical sign explicitly. Both need longitude wrapping; cylindrical projection is undefined at the vertical poles.

The pattern across the three is one tradeoff stated plainly, and it is unavoidable: you cannot simultaneously cover a very wide field of view and keep all straight lines straight on a flat output. This is the cartographer's dilemma: you cannot flatten a sphere onto a plane without distortion, which is why every world map lies about something (areas, angles, or distances). Planar buys straight lines at the cost of field of view; cylindrical and spherical buy field of view at the cost of bent lines. So pick by content: lots of straight architecture and a modest sweep favor planar; a wide landscape turn favors cylindrical; an immersive 360° surround demands spherical (Figure 20.4.2). Cartographers face the very same menu of compromises (Figure 20.4.1).

fig-xkcd-977
Figure 20.4.1. xkcd #977 "Map Projections", Randall Munroe, xkcd.com/977 (CC BY-NC 2.5).
fig-projections-three
Figure 20.4.2. Three projection surfaces for the same wide scene, and the unavoidable "straight lines bend" tradeoff. Planar: the mosaic is unrolled onto a flat plane: straight lines stay straight, but the corners stretch and the field of view (FOV) is capped near 120° (a single straight architectural edge stays perfectly straight, yet the projection cannot be pushed wider without the corners flying off to infinity). Cylindrical: unrolled from a cylinder, so vertical lines stay straight and the horizon is a straight band, but off-horizon horizontals bend; the same straight edge now bows into a curve while the projection comfortably wraps a full horizontal 360°. Spherical / equirectangular: unrolled from a sphere, a full $360° \times 180°$ surround in which almost every straight line curves and the poles stretch. You can have straight lines or a very wide field of view, not both on one flat output: the cartographer's dilemma. The caption beside each panel states when to use it.

Because the projection is just a re-parameterization of the output canvas, nothing stops you from choosing a deliberately creative one. The stereographic "little planet" projects a full $360°$ panorama from the zenith down onto a plane, wrapping the horizon into a circle and curling the ground into a tiny world seen from above: the same registered mosaic, unrolled for effect rather than fidelity. It is the playful end of the same freedom bundle adjustment and blending exist to protect.

fig-little-planet
Figure 20.4.3. The same panorama, two projections. Top: a wide equirectangular strip, the world wrapped onto a cylinder/sphere and unrolled flat. Bottom: the stereographic "little planet" reprojection of the same data: projecting from the zenith places the nadir at the center and the horizon/zenith at the rim, curling a city skyline into a tiny planet (a second example on Mars). Once the frames are registered, the output projection is a free downstream choice.

An equirectangular map and a perspective viewer represent the same directions differently. The horizontal coordinate wraps in longitude; the poles collapse many coordinates onto one direction. A perspective viewport samples a curved footprint in that map, not a rectangular vertical slice. Street-level map imagery is the familiar case. A vehicle-mounted rig records a full sphere of directions at each stop, the panorama is stored in a spherical format, and the browser shows a perspective window into it that follows the viewer's drag. Moving to the next stop loads the next panorama rather than moving within one; the change of viewpoint between stops is parallax, which a single panorama cannot represent.

fig-pano-equirect
Figure 20.4.4. The flat side of the sphere. The same default panorama the interactive viewer below loads, shown as the raw equirectangular image the stitcher produces: longitude (compass direction) runs across the full width and the left and right edges are the same seam; latitude (floor → sky) runs up the height, with the horizon a straight mid-line and the poles (zenith straight up, nadir straight down) each a single point stretched into the entire top or bottom row. Every direction the viewer can point is one vertical slice of this strip. Panorama courtesy of Poly Haven (CC0).
fig-pano-viewer
Figure 20.4.5. Look around a 360° panorama (interactive). The equirectangular mosaic is texture-mapped onto the inside of a sphere and viewed from its center: drag to pan and tilt, scroll / pinch to change the field of view. Widen the field of view and the straight quay and building edges bow outward, the very flatten-a-sphere distortion the projections above trade against, now something you can dial. Load your own 2:1 equirectangular image (a phone "Photo Sphere", a 360 camera, or your own stitched panorama) to fly around it. Default panorama courtesy of Poly Haven (CC0).

20.4.2 Bundle adjustment⧉

The naive pipeline builds a multi-image panorama the obvious way: it estimates each homography between adjacent frames and composes them to relate distant frames: $H_{13} = H_{23} H_{12}$, and so on around the sequence. Each pairwise homography carries a small estimation error, and composing a chain of them accumulates those errors. The symptom is unmistakable on a closed loop: shoot a full 360° panorama and, by the time the chain comes back around to where it started, the two ends do not meet, and there is a visible gap or vertical step at the closure (Figure 20.4.6). Sequential estimation lets error pile up and dumps the whole accumulated discrepancy at the seam.

Joint camera optimization uses all verified overlap constraints rather than committing permanently to pairwise estimates (Brown & Lowe 2007; Triggs et al. 2000). It distributes residuals according to geometry, confidence and loss, not necessarily evenly. Inconsistent data or an incorrect motion model can still leave a visible closure error.

Let $R_j$ map camera-$j$ rays to a common world frame. Predict a match from image $j$ in image $k$ by $\hat x_{ik}=\pi(K_kR_k^{\mathsf T}R_jK_j^{-1}\tilde x_{ij})$, including distortion in the projection functions when modeled. Fit the observed two-dimensional positions $x_{ik}$:

$$\min_{\{\theta_j\}}\sum_{(j,k),i}\rho\!\left(\lVert\hat x_{ik}(\theta_j,\theta_k)-x_{ik}\rVert_2^2\right).$$

The solve minimizes match residuals over the connected overlap graph. Fix one camera orientation to remove the global-rotation gauge; constrain calibration parameters that the data cannot determine reliably. Initialize from validated pairwise estimates and use nonlinear least squares with a declared outlier-resistant loss. A global formulation is not a global-optimum guarantee.

Geometric reprojection residuals do not constrain exposure gains. Photometric consistency needs a separate term using valid, corresponding image intensities. Geometry and photometry can be solved jointly or in alternating stages; both designs can work.

The first is gain (exposure) compensation. Frames shot around a panorama rarely share an exposure exactly (auto-exposure drifts, the sun moves behind a cloud), so the overlaps disagree in brightness. Assign each image a per-image gain $g_j$ (and optionally a per-channel white balance) and choose the gains so that overlapping pixels agree photometrically:

$$ \min_{\{g_j\}} \ \sum_{(j,k)} \sum_{p \in \text{overlap}} \big( g_j I_j(p) - g_k I_k(p) \big)^2 \;+\; \lambda \sum_j (g_j - 1)^2. $$

The first term pulls the overlapping brightnesses into agreement; the regularizer $\lambda \sum_j (g_j-1)^2$ keeps every gain near 1 so the whole panorama does not drift uniformly dark or bright (the trivial all-zero solution that the first term alone would happily accept). Solving this before the seam blend removes most of the exposure mismatch up front, which is exactly what makes the blending of the previous chapter easy, because a blender hides a small residual mismatch far more gracefully than a large one.

The second is vignetting, the radial brightness falloff that darkens a lens's corners relative to its center. A per-lens falloff model is estimated jointly so that the same scene point matches in brightness whether it happens to land at the center of one frame or the corner of the next. And one can fold in radial distortion as well: the barrel or pincushion warp that bends straight lines near the frame edge, modeled as

$$ r_d = r\,(1 + \kappa_1 r^2 + \kappa_2 r^4), $$

with the distortion coefficients $\kappa$ added to the per-camera parameters $\theta_j$ so that straight scene lines align across frames rather than fighting the homography at the seams. (The distortion model itself is developed in Chapter 22.2, Aberrations correction; here it is simply another set of unknowns in the global fit.)

Check geometric residuals and photometric residuals separately. Fixing gauges, rejecting invalid overlaps and calibrating lens behavior matter more than whether the implementation is described as one solve or several.

fig-bundle-drift
Figure 20.4.6. Why pairwise chaining drifts, and how bundle adjustment fixes it. Top, chained homographies: a 360° loop registered by composing adjacent homographies $H_{13}=H_{23}H_{12},\dots$; each pairwise error accumulates, so where the loop should close the two ends fail to meet, a visible gap or vertical step. Bottom, bundle-adjusted: all cameras' parameters are optimized jointly to minimize total reprojection error, so the residual is distributed evenly around the loop and the closure is seamless. Sequential estimation piles error up at the seam; the global solve spreads it out until it vanishes.

20.4.3 Movement and parallax handling⧉

The previous two sections repaired the geometry and photometry of the panorama while still assuming two things the world routinely violates: that the scene is static, and that the camera only rotated. This section is what happens when each of those assumptions breaks. The first failure, something moved between frames, is fixed by a tool you already have. The second, the camera translated, is a genuine limit of the homography model, and worth understanding precisely so you know when to stop fighting it.

Deghosting: one source per moving region⧉

After background alignment, moving subjects can remain displaced. Local correspondence can align some of them, but occlusions and differing exposure blur leave unsupported regions. Source selection is another option; it needs a policy for which moment to show.

Large overlap differences flag inconsistency, which can come from motion, parallax or photometric error. Use those diagnostics and, where needed, object masks or user constraints to prefer a coherent source for each subject.

Source selection is the seam-optimization problem of Chapter 10.9, Seam optimization with one extra consideration in the cost. Recall the seam energy from Chapter 20.3, Blending, $E = \sum_p D_p + \sum_{pq} V_{pq}$: a per-pixel data cost $D_p$ for the frame each output pixel is drawn from, plus a smoothness cost $V_{pq}$ for switching frames between neighbors. Deciding which frame supplies each moving region is exactly such a per-pixel labeling. Make the smoothness cost high where the aligned frames disagree, so that cutting through a moving blob is expensive and cutting around it is cheap, and a graph-cut optimizer (Boykov, Veksler and Zabih, 2001) routes the seam around the object, then the pyramid or Poisson machinery of Chapter 6.6, Pyramids and wavelets and Chapter 10.8, Poisson image editing blends along it (Figure 20.4.8). Deghosting is the blending chapter's seam energy with motion disagreement folded into the cut cost: the energy is the design.

A seam energy can discourage cuts through a moving region, but ordinary local costs do not guarantee a whole object receives one label. Enforce that requirement explicitly when it matters. Removing all copies of a passerby also requires background observations to fill the uncovered area.

The multiplicity case is also the easiest to cause on purpose (Figure 20.4.7). A phone's sweep panorama builds the image from a continuous series of slices as you pan; if a subject runs behind the camera and back into a not-yet-captured part of the sweep, they are photographed more than once, landing in the panorama several times over. Two children who keep darting to the far end of the pan become four, or six: the static-scene assumption broken deliberately instead of repaired.

fig-pano-multiplicity
Figure 20.4.7. Breaking the static-scene assumption for fun. A phone sweep-panorama of a living room: as the camera panned, the two children sprinted around behind it to reappear further along the sweep, so each is captured twice and the finished panorama shows four children where there are two. It is the same moving-subject "ghost" the deghoster works to suppress, here welcomed instead, the playful inverse of removing a passer-by. Image courtesy of Laelia Durand, Téo Durand, and Maïlys Durand.

Parallax: when translation breaks the homography⧉

The deeper limit is geometric, and it is not a bug to be tuned away. Recall from Chapter 20.1, Manual panorama stitching from multiple views why a homography can align two frames in the first place: it is exact under a central-camera model for pure rotation about the projection center or points on a plane; a very distant scene can make translation effects negligible. Under pure rotation every scene point, near or far, moves between the two views by the same projective map, which is what let a single $3 \times 3$ homography $H \simeq K R K^{-1}$ stand in for the whole scene, with no dependence on depth.

The moment the camera translates (the photographer takes a step sideways), that guarantee collapses. Now near and far objects shift by different amounts: this is motion parallax, the everyday effect by which nearby fence posts streak past a train window while distant mountains barely move. And no single homography can align both: line up the background and the foreground doubles; line up the foreground and the background tears (Figure 20.4.9).

Translation makes correspondence depend on scene depth, so one projective transform generally cannot describe the whole overlap. A local displacement field can encode that variation where correspondence exists; a single global homography cannot.

Because the limit is structural, the practical escapes either avoid the translation or stop using a homography:

A handheld sweep may include viewpoint translation and rolling-shutter motion. Their magnitude depends on capture, and narrow strips can conceal some mismatches without making the underlying central-camera assumptions exact.

fig-deghost-seam
Figure 20.4.8. Deghosting as a seam choice over moving regions. A person walks through the overlap between two frames and so appears in two different places. Naive blend: cross-fading the overlap averages the two positions, leaving the person doubled and translucent, a ghost. Deghosted: the disagreement region (large per-pixel difference after alignment) is detected, and the graph-cut seam is routed around the moving blob so the person is taken whole from a single frame, then blended along that seam. Same machinery, flipped: keep every copy for a stroboscopic pano, or keep none to erase transient people.
fig-parallax-breaks-homography
Figure 20.4.9. Parallax: why a translated camera breaks the homography. The camera takes a step sideways between two shots, so a near object and a far object shift by different amounts (motion parallax). Align on the background: the distant wall registers perfectly, but the near object is doubled. Align on the foreground: the near object registers, but the background tears. No single 2-D homography can satisfy both at once, because translation through a 3-D scene produces a depth-dependent displacement an 8-degrees-of-freedom (DOF) global warp cannot represent. The cure is to pivot about the no-parallax point, route the seam through far regions, or go fully 3-D.

Source selection makes several different composites possible. In an overlap containing a walking person, assigning the whole person to one frame can avoid a translucent double exposure. Choosing separate complete appearances can intentionally make a sequence-of-motion composite. Removing the person altogether requires some source to show the background behind each removed region. A seam cost can favor cuts around the person, but if keeping an object whole is a requirement, that requirement must be encoded rather than assumed to follow from local smoothness. Blend after selecting content; blending alone cannot decide which event the panorama should depict.