Part II · Geometry & The 3D World · Chapter 06

Stitching & Alignment

How does a phone scanner flatten a crooked receipt on a desk, or stitch a dozen mountain snapshots into one sweeping panorama? Both rely on the same geometric superpower: matching landmarks to warp one view onto another.

Imagine snapping a photo of a book cover or a street sign from off to the side. Because of Chapter 4's perspective rules, the closer edge of the rectangle looks taller than the farther edge, turning a neat square into a slanted trapezoid.

Yet you never confuse a tilted book for a strangely shaped trapezoid — your brain effortlessly "un-tilts" it back into a flat rectangle. Computers can perform the exact same visual magic using a perspective warp called a homography. And here is the surprising part: to completely lock down how any flat surface is tilted in 3D space, you only need four corner anchor points.

Why Four Corners Lock Down Any Flat Plane

Think about pinning a stretchy rubber sheet onto a wall:

Try it yourself below. Grab the four glowing gold corner handles on the left and drag them onto the corners of the tilted poster. Watch the right-hand screen live-unwarp the crooked photograph into a crisp, straight-on flat image!

Interactive Lab 6.1 4-Corner Perspective Warper (Homography Intuition)

Drag the 4 glowing gold corner handles on the left to hug the tilted book cover. Watch the unwarped front-facing view update in real time on the right!

Anchor Points: 4 corners (full plane lock) Surface Match: Slightly misaligned Effect: Un-tilting perspective
✦ Key Relationship · Flat Surfaces & Spinning Cameras

This four-corner perspective warp works perfectly in two everyday situations: whenever you look at a flat surface (like a page, whiteboard, billboard, or sports field), or whenever a camera spins in place without walking sideways (like standing on a mountaintop and sweeping your phone across the horizon).

Stitching Panoramas — And Ignoring Bad Matches

Now suppose you take two overlapping photos of a night sky over a mountain ridge and want to stitch them into one wide panorama. First, the computer finds distinctive corners and landmarks in both photos (using the visual fingerprints from Chapter 3) and pairs up matching spots between the left photo and the right photo.

There's just one messy real-world catch: feature matching isn't perfect. Two different stars look almost identical, and jagged rocky peaks can fool the matcher into drawing wildly wrong lines across the image. These false connections are called outliers.

If the computer blindly averages all the matches together — good and bad — the outliers yank the panorama into a twisted mess. How does a smart vision system separate truth from noise? It holds a rapid-fire consensus vote (an idea famously known as RANSAC):

  1. Pick a tiny random handful of matches and test what alignment they predict.
  2. Count how many other matches agree with that exact same alignment.
  3. Repeat a few times and crown the alignment with the biggest crowd of supporters — throwing away every outlier that disagrees!

Interactive Lab 6.2 Panorama Stitcher & Outlier Filter

Turn on Bad Matches (Outliers) to see how false landmark pairs cross wildly in coral. Then click "Let Consensus Vote" to watch the consistent matches outvote the noise and lock the two photos into one seamless panorama!

True Matches: 7 consistent links Bad Matches: 5 conflicting links Status: Inspecting overlaps
? Pause & Think

When you take a panorama on your smartphone, the app tells you to spin smoothly in one spot rather than walking sideways down the sidewalk. Thinking back to Chapter 5's parallax, why does walking sideways ruin a flat panorama stitch?

If you walk sideways, nearby objects (like a streetlamp or a friend) shift much faster across the frame than distant buildings behind them. No single flat warp can line up both the foreground and the background at the same time — so the stitched seam ends up with "ghosts" or sliced-in-half objects! Spinning in place keeps all parallax at zero so the whole scene acts like one giant flat canvas.

★ Core Intuition · Geometry Meets Meaning

Pause and appreciate how far we've traveled across Part II! With nothing more than straight light rays, two viewpoints, and four-corner consensus alignment, a machine can undo perspective tilt, measure 3D depth, and stitch whole landscapes together.

Yet our machine still has a blind spot: it can measure a mountain's distance and flatten a book cover, without having any idea what a "mountain" or a "book" actually is. In Part III, we step into the world of learning — teaching machines to recognize meaning itself.

Chapter 6 Takeaways

  • A flat surface viewed from an angle can be unwarped into a front-facing rectangle using just four corner anchor points (a perspective warp, or homography).
  • Real-world landmark matchers inevitably produce false pairs called outliers that pull naive alignments off course.
  • Consensus voting (RANSAC) finds the alignment supported by the largest consistent group of matches and discards conflicting outliers automatically.
  • Once aligned, overlapping photos blend smoothly into a single wide panorama — as long as the camera rotates in place without sideways parallax.