Algorithm Search⌘K

Techniquecore

Left-right consistency check

Also called left-right check, cross-checking of disparities.

Compute disparity maps with each image as reference and invalidate the pixels whose two disparities do not map back to each other, which marks occlusions and many mismatches.

The left-right consistency check computes a disparity map dLd_L with the left image as reference and a map dRd_R with the right image as reference, and keeps the left pixel (u,v)(u, v) only if the right pixel it points to points back: ∣dL(u,v)−dR(u−dL(u,v),v)∣≤τ|d_L(u, v) - d_R(u - d_L(u, v), v)| \le \tau for a small threshold τ\tau, usually 1 pixel or 0 for integer maps. A pixel whose scene point is hidden in the right image has no true match, so its two disparities seldom agree, and many plain mismatches in flat or repeated areas fail the test too. Fua (1993) used the test to keep only reliable matches. With a cost volume, the right map comes almost free from the same costs, so semi-global matching and most local methods use the check before they fill the invalid pixels. The same idea appears in tracking as the forward-backward error and in feature matching as mutual nearest neighbors.

In plain words

Match each pixel of the left image into the right image. Then do the same thing the other way, from the right image back into the left. If a left pixel goes to some right pixel, and that right pixel comes back to the same left pixel, the match is probably right. If it comes back somewhere else, something is wrong: either the left pixel sees a part of the scene that the right camera cannot see, or the matcher was confused. Mark such pixels as unknown, and fill them later from good neighbors.

When it applies

  • The method can compute a disparity map with either image as reference. With a cost volume this costs only a second winner-takes-all on the sheared volume; with other methods it costs a second full run.
  • Wrong disparities are worse than missing ones, as in 3D reconstruction, robot navigation or depth map fusion, where an invalid pixel is skipped but a wrong one creates a false surface.
  • The scene has depth edges, so that some pixels are half occluded: seen by one camera only. These are the pixels next to the left side of a near object in the left image.

The template

  1. LR-CHECK(d_L, d_R, τ)
  2. 1for each left pixel (u, v) do
  3. 2x ← u - round(d_L(u, v))
  4. 3if x < 0 or x ≥ W then valid(u, v) ← false
  5. 4else valid(u, v) ← |d_L(u, v) - d_R(x, v)| ≤ τ
  6. 5return valid

The right map uses the same sign: the right pixel (x,v)(x, v) matches the left pixel (x+dR(x,v),v)(x + d_R(x, v), v). The holes are the threshold τ\tau and what happens to the invalid pixels afterwards. A common fill takes, for each invalid pixel, the valid disparities nearest to it on its row to the left and to the right, and keeps the smaller one, because a half occluded pixel belongs to the background, which has the smaller disparity. A median filter of the result removes the streaks this fill leaves. Hirschmüller (2008) also separates the two kinds of failure: an invalid pixel is a mismatch if some other disparity of its column would be consistent, and an occlusion otherwise, and the two kinds are filled differently.

What the check guarantees. If dLd_L and dRd_R are the true integer disparity maps of a scene, every left pixel whose scene point is visible in the right image passes with τ=0\tau = 0, because the right pixel sees the same point at the same depth. A left pixel whose point is hidden points to a right pixel that sees a nearer point, with a larger disparity, so it fails if that disparity is larger by more than τ\tau. So with true maps and τ=0\tau = 0 the check flags exactly the half occluded pixels and the pixels whose match is outside the right image. With estimated maps there is no such guarantee: two maps can agree on the same wrong match, for example on a repeated pattern, and the check then passes a wrong pixel.

Classic examples

A step edge. Take a row of 10 pixels. A background plane has disparity 1 and a near object, the left pixels 5 to 7, has disparity 3. Suppose the matcher returns the true disparity wherever there is one and the background disparity elsewhere:

left pixel uu 0 1 2 3 4 5 6 7 8 9
dL(u)d_L(u) 1 1 1 1 1 3 3 3 1 1
x=u−dL(u)x = u - d_L(u) −1-1 0 1 2 3 2 3 4 7 8
dR(x)d_R(x) 1 1 3 3 3 3 3 1 1
valid no yes yes no no yes yes yes yes yes

The right map is dR=(1,1,3,3,3,1,1,1,1,1)d_R = (1, 1, 3, 3, 3, 1, 1, 1, 1, 1): the right pixels 2 to 4 see the near object. The pixels 3 and 4 fail: their background is hidden behind the object in the right image, and the number of such pixels is the jump of disparity, 3−1=23 - 1 = 2. Pixel 0 fails because its match is outside the right image. The fill gives pixels 3 and 4 the smaller of the nearest valid values 1 (pixel 2) and 3 (pixel 5), which is the true background disparity 1.

In stereo methods. Semi-global matching computes dRd_R from the right view of the same cost volume and checks with τ=1\tau = 1. Block matching implementations such as OpenCV's add the check as an option. Learned methods use it to mark pixels for which the network output should not be trusted.

Beyond stereo. In optical flow and tracking, a point is tracked forward and then backward, and a large forward-backward error marks it as unreliable. In feature matching, keeping only mutual nearest neighbors is the same test on discrete matches. In multi-view stereo and depth map fusion, a depth is kept only if other views confirm it by projecting it back.

Variations

  • Threshold. τ=0\tau = 0 for integer maps keeps only exact agreement; τ=1\tau = 1 allows rounding and subpixel differences. With subpixel maps, round u−dL(u,v)u - d_L(u, v) to the nearest pixel or interpolate dRd_R.
  • One-sided check from one volume. Instead of a second map, test whether the right pixel xx has its least cost at uu among all left pixels that can match it. This is the same test written on the cost volume.
  • Uniqueness constraint. Allow each right pixel to be the match of at most one left pixel. This is weaker: it does not test that the right pixel points back.
  • Occlusion in the model. Graph cut and dynamic programming methods can label pixels as occluded inside the optimization instead of after it.

Pitfalls

  • Sign of the right map. The right pixel (x,v)(x, v) matches the left pixel (x+dR,v)(x + d_R, v). Using x−dRx - d_R makes almost every pixel fail.
  • Not a correctness proof. Agreement does not prove a match. On repeated textures both maps can make the same mistake.
  • Twice the work. Without a cost volume, the right map needs a second full run of the matcher.
  • Filling from the wrong side. Filling a half occluded pixel with the larger, foreground disparity grows the near object. Use the smaller one, or the one on the background side.
  • Thin structures. Objects narrower than the window are often matched in one direction only and are removed by the check, together with real occlusions.

References

  1. Pascal Fua, A parallel stereo algorithm that produces dense depth maps and preserves image features, Machine Vision and Applications 6(1), 1993, 35-49, the validity test that keeps a match only if the correlation from the left and from the right image gives the same pair
  2. Heiko Hirschmüller, Stereo processing by semiglobal matching and mutual information, IEEE Transactions on Pattern Analysis and Machine Intelligence 30(2), 2008, 328-341, the part on the consistency check, the right disparity map from the same cost volume, and the separation of occlusions from mismatches
  3. Daniel Scharstein and Richard Szeliski, A taxonomy and evaluation of dense two-frame stereo correspondence algorithms, International Journal of Computer Vision 47(1-3), 2002, 7-42, the part on refinement and on occlusion detection by cross-checking
  4. Richard Szeliski, Computer Vision, Algorithms and Applications, second edition, Springer, 2022, Chapter 12, Depth estimation (cross-checking of disparity maps and the handling of occlusions)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • three classic examples