Problemcore
Stereo matching
Also called stereo correspondence, dense stereo.
For each pixel of one rectified image, find the disparity of the matching pixel in the other image of a stereo pair.
Stereo matching is the problem of finding, for each pixel of one image of a rectified stereo pair, the disparity of the pixel in the other image that sees the same scene point. After rectification the match lies in the same row, so the search is one dimensional, over a range of disparities. The result is a dense disparity map, which depth from disparity turns into depths. The problem is hard because many pixels look alike (textureless areas, repeated patterns), because some pixels have no match at all (occlusions), and because the two cameras see a surface under slightly different light and shape.
In plain words
You have two photos taken side by side, already lined up so that each row of one photo shows the same strip of the scene as the same row of the other. For each pixel of the left photo, find where the same spot of the scene is in the right photo. It is somewhere to the left in the same row, and the distance is the disparity. Comparing single pixels does not work well, because many pixels have the same color. So every method compares small areas, or asks that neighbors have similar disparities, or both. Some pixels see a part of the scene that the other camera cannot see, and they have no correct answer.
Definition
Input. Two rectified images and of pixels, with the right camera at the baseline along of the left one, and a disparity range (or ). Pixel is in column and row .
Output. A disparity map that gives each pixel of the left image a disparity , so that in and in see the same scene point. The map can also mark pixels as invalid. Disparities are integers or, after refinement, real numbers.
What counts as correct. The problem is an estimation problem: the true disparity is a property of the scene, and the images do not determine it. Benchmarks compare with a ground truth map and count the bad pixels, the pixels with for a threshold such as 1 pixel, in all areas, in textureless areas and near depth edges (Scharstein and Szeliski 2002).
Energy form. Most methods choose to make an energy small:
where is the matching cost of pixel at disparity , stored in a cost volume, is the set of neighbor pairs, and is a smoothness term such as the Potts term or a truncated linear term. Local methods drop the second sum and use an aggregated cost in the first. The energy is a model, not the definition of correct: the minimum of is not always the true map.
Variants
- Sparse matching. Match only distinctive points, as in feature matching. Dense matching, the subject here, gives every pixel a value or marks it invalid.
- Integer or subpixel. Integer disparities, then subpixel refinement to a fraction of a pixel.
- With occlusions. Mark each pixel as matched or occluded, often by a left-right consistency check or inside the energy.
- Unrectified or many views. Search along epipolar lines that are not rows, or use many cameras: plane sweep stereo and multi-view stereo.
- Motion. Without rectification and with moving objects, the match is a 2D vector: optical flow, and with depth, scene flow.
Examples
One row. Let the right row be and the left row its shift by one pixel, , so the true disparity is 1 everywhere. With the cost and :
- At () the costs for are . The match is clear: .
- At () the costs are : again .
- At () the costs are , because is at columns 5, 4 and 3. Each disparity fits, and one pixel cannot decide.
- At the costs of the pixel alone are , a tie between and . The window of columns 3 to 5 gives the sums , because it contains the textured pixel at , and the tie is gone. At the window of columns 4 and 5 still gives : it is too far from the texture.
This is the problem of textureless areas: the answer must come from neighbors, by a larger window, by aggregation or by a smoothness term.
Occlusion. In the left image, the background just left of a near object is hidden from the right camera. Those pixels have no true match, and any method that gives every pixel a disparity is wrong there.
Known algorithms
The taxonomy of Scharstein and Szeliski (2002) splits a stereo method into four steps: matching cost, aggregation, disparity computation or optimization, and refinement. The pages of this area follow it.
| method | step it is about | time | model |
|---|---|---|---|
| block matching | box aggregation and winner-takes-all | local | |
| census transform | a matching cost robust to light changes | for the costs | local |
| adaptive support weights | aggregation with edge-aware weights | local | |
| guided filter aggregation (Hosni et al. 2013), see cost aggregation | edge-aware aggregation in time independent of | local | |
| scanline dynamic programming | exact minimum of on each row alone | per row for simple | global on a row |
| semi-global matching | sums of 1D minimizations along 8 or 16 paths | per path | semi-global |
| graph cut stereo, alpha expansion | approximate minimum of on the 2D grid | a min cut per move | global |
| belief propagation | approximate minimum by messages on the grid | per iteration with fast messages | global |
| PatchMatch stereo | random search over slanted planes | independent of | local with propagation |
| Algorithm | Time | Space | Properties | Code |
|---|---|---|---|---|
| Adaptive support weights | Θ(W H D r^2) worst · average · best | Θ(W H r^2) extra | deterministicnot exactofflineiterative | 1 language |
| Block matching stereo | Θ(W H D) worst · average · best | Θ(W H) extra | deterministicexactofflineiterative | 1 language |
| Graph cut stereo | O(k D (F + n)) worst · average | O(n) extra | deterministicnot exactofflineiterative | 1 language |
| PatchMatch stereo | Θ(T W H s log D) worst · average · best | Θ(W H) extra | randomizednot exactofflineiterative | 1 language |
| Plane sweep stereo | Θ(D N W H) worst · average · best | Θ(W H) extra | deterministicnot exactofflineiterative | 1 language |
| Dynamic programming stereo | Θ(W H D) worst · average · best | Θ(W D) extra | deterministicexactofflineiterative | 1 language |
| Semi-global matching | Θ(W H D R) worst · average · best | Θ(W H D) extra | deterministicnot exactofflineiterative | 1 language |
Bounds
- Output size. Any method writes values, so it takes time. A method that looks at every disparity of every pixel, as a full cost volume does, takes . PatchMatch avoids the factor by sampling.
- Local methods. With box aggregation by running sums or an integral image, winner-takes-all takes time, independent of the window size.
- One row. The energy restricted to one row is a chain, and dynamic programming finds its exact minimum in time, or for the Potts and linear terms.
- The full grid. Minimizing on the 2D grid with the Potts term is NP-hard (Boykov, Veksler and Zabih 2001), by a reduction from multiway cut. For a convex of , an exact minimum is computable by one minimum cut on a graph of nodes (Ishikawa 2003). In practice the methods above are approximations, and their quality is measured on benchmarks, not proved.
Reductions
- To labeling. Stereo matching with the energy is a labeling problem on a Markov random field with labels per pixel. Any MRF method applies, which is why graph cuts and belief propagation entered stereo.
- From general camera pairs. An unrectified pair reduces to this problem by stereo rectification, as long as the epipoles are outside the images.
- To optical flow. Stereo matching is optical flow with the vertical component fixed at zero and the horizontal one at most zero. A flow method can solve it, with more work and less accuracy.
- To depth. A disparity map gives a depth map by , see depth from disparity.
Applications
Depth for robots, cars and drones from a pair of cameras; 3D models of buildings and terrain from aerial images; depth for view synthesis and refocusing in phone cameras; and the first step of depth map fusion in 3D scanning.
References
- 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 whole paper (the four steps of matching cost, aggregation, optimization and refinement, the taxonomy of methods, and the evaluation by the percentage of bad pixels)
- Richard Szeliski, Computer Vision, Algorithms and Applications, second edition, Springer, 2022, Chapter 12, Depth estimation (dense correspondence, local methods and global optimization)
- Yuri Boykov, Olga Veksler and Ramin Zabih, Fast approximate energy minimization via graph cuts, IEEE Transactions on Pattern Analysis and Machine Intelligence 23(11), 2001, the proof that minimizing the energy with the Potts smoothness term is NP-hard, and the expansion and swap moves
Where this leads
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.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag KDEN2N Edit this page History Report an error Markdown