Quiz: stereo, from disparity to depth
Before this unit: Two views: epipolar geometry, triangulation (previous unit); Day 52: 3D graphics.
See also: Day 24: Keypoints and descriptors; Day 21: Hough transform; Day 23: FFT registration.
Short questions to test your understanding. Try each on paper first, then open the answer. Disparity d = x - x' (left minus right column).
Q1. What does rectification do, and why is it worth the extra resampling?
Where are the epipolar lines afterwards?
It warps both images (one homography each, as if both cameras were turned to a common orientation along the baseline) so that the epipolar lines become the same image rows. A match is then on the same row, and matching is a 1D search along it; costs for all pixels and disparities can be computed with simple shifted window sums.
Q2. A stereo camera has f = 1400 px and B = 0.1 m. A point has disparity 35 px. How far is it? Roughly how much does one pixel of disparity error change its depth?
Z = fB/d, \delta Z \approx Z^2/(fB) per pixel.
Z = 140/35 = 4 m; \delta Z \approx 16/140 = 0.11 m per pixel (140/34 - 4 = 0.12 m exactly).
Q3. The right camera’s images are 20 % brighter than the left camera’s. Which matching cost should you use, and which should you avoid?
Which costs compare raw brightness values?
Avoid SAD and SSD: they see the brightness difference as a mismatch everywhere. NCC (gain and offset removed per window) and census (only the order of brightnesses) are unaffected; census also copes with nonlinear brightness changes.
Q4. Why do large matching windows make foreground objects look wider than they are?
Consider a background pixel right next to the object.
The window around a background pixel near the edge contains part of the foreground object. If the object is well textured, its part of the window dominates the cost, and the best disparity is the object’s. So the object’s disparity spreads by up to half a window beyond its true edge.
Q5. Why does every stereo pair have pixels without a correct match, and where are they?
What does the right camera see behind the left edge of a near object?
At every depth edge, a strip of background is visible to one camera and hidden behind the near object for the other: occlusion. In the left image these pixels lie just left of near objects. They have no match; the left–right check marks most of them invalid.
Q6. What does the left–right check do, and why is “invalid” a better result than “depth 0” for a failed pixel?
Match in both directions.
Compute disparities from the left image and from the right image; keep a left pixel only if the right image’s disparity at its match points back (within one pixel). Occluded and ambiguous pixels usually fail. “Invalid” is honest and can be filled or ignored later; a made-up value (depth 0, or a wrong disparity) becomes a wrong 3D point that nothing downstream can recognise.
Q7. Scanline dynamic programming and semi-global matching both add a smoothness cost. What is the visible difference in their results, and why?
Along which lines does each one pass information?
Scanline DP solves each row independently, so a row that goes wrong is not corrected by its neighbours: horizontal streaks. SGM runs the same 1D recursion along 4 or 8 directions (including vertical and diagonal) and sums them, so evidence also flows between rows: far fewer streaks.
Q8. (math) The costs at disparities 7, 8, 9 are 6, 2, 4, and 8 is the integer minimum. Where is the sub-pixel minimum by a parabola fit?
\delta^* = (C_- - C_+)/(2(C_- - 2C_0 + C_+)).
\delta^* = (6 - 4)/(2(6 - 4 + 4)) = 2/12 = 0.17: d = 8.17, towards the cheaper neighbour 9.