EECE 5554 Robotics Sensing and Navigation  /  Interactive demo

Disparity by block matching

After rectification, a pixel’s match is on the same row of the other image, shifted by its disparity. Block matching tries every shift and keeps the window that matches best. Change the window, turn on the checks that real matchers use, and see where stereo works and where it fails.

Runs block_matching.pyLecture 13
Starting...

Matcher

Window size

Say "I don't know"

Uniqueness margin

Search: 0 to 31 px. The scene: a textured far wall (d = 5), a plain wall on the left (d = 11), a near box (d = 20), and a fence with stripes every 8 px (d = 8).

Left image

Right image: everything shifted left by its disparity

Disparity found: warm is near, cool is far, dark is invalid

True disparity, for comparison

Try this

  1. Start with a 5 × 5 window. The textured areas are right but speckled; the plain wall on the left is a mess, because every window there looks the same.
  2. Make the window 15 or 21. The speckle goes away, but the box edges get fat: a big window mixes the near box with the wall behind it.
  3. Look at the fence on the right. Its stripes repeat every 8 pixels, so several shifts match equally well. A bigger window reaches the ends of the fence and helps.
  4. Turn on a 15% uniqueness margin and the left-right check. About half the pixels lose their depth, and nearly all that remain are right. A hole is honest; a wrong depth is dangerous.

Notebook

Work with the same script in cells, like Jupyter, right here in the browser. Edit any cell and run it. Nothing is saved: Reset brings a cell back, and Download .ipynb keeps your edited version for VS Code or Jupyter.

Loading Python...
The Python script: block_matching.py

This is the script the page runs. Run it yourself with python3 block_matching.py.

block_matching.py