AI Glossary / Computer vision and multimodal AI / Beginner

Disparity map

Definition

A disparity map records the positional differences of corresponding scene points between two images, usually a stereo pair. In a horizontally rectified stereo setup, each valid map value commonly represents a horizontal pixel displacement. With suitable calibration and geometry, those disparities can be converted into depth estimates.

What it means

Hold a finger in front of your face and alternate between your eyes. Its apparent position changes relative to the background. Stereo vision uses the same underlying idea: nearby and distant surfaces produce different image displacements between separated viewpoints.

A disparity map stores estimated displacement across an image rather than just for one point. Its values are not automatically distances in meters. They depend on image coordinates, the sign convention, and how the software encodes the output.

Disparity and depth are related but different representations. Under a common calibrated, rectified model, larger positive disparity corresponds to smaller depth. Some pixels have no reliable correspondence at all, so a useful map must also represent invalid or uncertain estimates rather than pretending every location has a valid measurement.

How it works

Capture two views with known camera relationships. Correct relevant lens effects and rectify the pair so corresponding points lie on matching image rows in the usual horizontal configuration.

Estimate correspondences using image patterns, learned features, or another matching method. A matcher searches possible displacements and selects or estimates the most plausible one for each location or region.

Apply consistency checks and other processing to identify ambiguous, noisy, or occluded locations. Textureless surfaces, repeated patterns, reflections, and differing visibility can all make matching difficult.

Interpret the resulting values using the algorithm's conventions. Some implementations store scaled integers rather than direct pixel disparities. To obtain depth, use the calibrated projection relationship, including any relevant image-origin or principal-point offsets. The familiar depth formula applies to a particular simplified rectified geometry, not every arbitrary pair of images.

Three practical examples

1. Robot navigation: A stereo system estimates the relative depth of visible surfaces from a disparity map and marks unreliable areas for further handling.

2. Three-dimensional capture: A scanning pipeline converts calibrated disparity estimates into points that can support a surface reconstruction.

3. Photography effects: A camera application uses estimated scene structure to guide selective blur, with special attention to object boundaries.

Think of it this way

Think of comparing two seating charts drawn from slightly different viewpoints and recording how far each matching seat appears to shift. The shift is evidence about geometry, but it is not itself a physical distance to the seat.

The analogy is limited because image matching may be ambiguous and some surfaces are visible in only one view. A disparity map contains estimated correspondences, not a guaranteed inventory of all scene points.

Worked example

Assume a calibrated rectified stereo pair with matching principal-point coordinates, focal length f = 700 pixels, and camera baseline B = 0.12 meters. For this simplified geometry, depth Z = fB/d, where d is disparity in pixels.

If a point appears at horizontal coordinate 250 in the left image and 222 in the right, its disparity is 250 - 222 = 28 pixels under that sign convention. Its estimated depth is 700 × 0.12 / 28 = 3 meters.

A second point with disparity 14 pixels has estimated depth 6 meters. Halving disparity doubles depth in this model.

Now consider a disparity error of one pixel. Using 27 instead of 28 gives approximately 3.11 meters; using 13 instead of 14 gives approximately 6.46 meters. The same pixel error produces a larger depth error for the more distant point. This illustrates why long-range depth accuracy requires careful evaluation rather than judging only the visual smoothness of the disparity map.

Illustrative case study

Fictional case study: ShelfDepth tests stereo cameras for measuring visible shelf geometry. A colorful disparity display looks convincing, but a plain white panel contains inconsistent estimates.

The team checks correspondence confidence and finds that the panel provides little distinctive texture. It introduces validity masks and evaluates measurements against reference distances instead of accepting every displayed color as a measurement.

It also documents the stored disparity scale before converting values to meters. The fictional case illustrates two practical failure sources; it does not imply that one filtering setting solves every low-texture or reflective-surface problem.

Common misconceptions and mistakes

Do not equate a disparity map with a depth map. One records correspondence displacement, while the other records a depth quantity after interpretation or estimation.

Do not convert display colors directly into metric distance unless the visualization's mapping is explicitly defined. A normalized preview may discard the numerical scale needed for measurement.

Do not treat invalid disparities as ordinary zero-distance or infinite-distance observations. Follow the output convention and preserve validity information.

Do not assume a smooth map is an accurate map. Filtering can hide mismatch artifacts while blurring real depth boundaries or spreading incorrect values.

Business use

Disparity maps support depth-aware automation, inspection, and visual effects. Their business value depends on reliable measurements across the actual working distances and materials, not simply on attractive demonstrations.

Ask how the system handles invalid matches, what calibration it requires, and how uncertainty changes with distance. Include reflective, repetitive, and low-texture surfaces in testing. Keep raw estimates, validity information, and conversion settings together so a questionable depth result can be traced back to its correspondence and calibration assumptions.

People also ask

Are disparity values measured in meters?

Usually they represent image displacement, commonly pixels or scaled pixel units. Calibration is needed for metric depth conversion.

Why are some locations invalid?

They may lack a reliable match because of occlusion, weak texture, repeated patterns, or other imaging problems.

Does greater disparity always mean closer?

That interpretation holds under the stated stereo geometry and sign convention; check the representation before applying it generally.

Check your understanding

In the simplified stereo formula Z = fB/d, what happens to depth when disparity doubles while focal length and baseline stay fixed?

Answer: Depth halves. The relationship is inverse, so the disparity must be interpreted with its calibration and units intact.

Related terms

  • Depth map
  • Epipolar geometry
  • Rectification
  • Correspondence problem
  • Stereo vision
  • camera calibration
  • occlusion

Learn next

Learn stereo rectification next to understand why correspondence search can be reduced to image rows. Then study uncertainty propagation to see how small disparity errors affect depth at different ranges.

  • Rectification

More in Computer vision and multimodal AI

  • Dirichlet boundary condition - A Dirichlet boundary condition specifies the value of an unknown function on a selected boundary of a mathematical domain.
  • Dirichlet distribution - The Dirichlet distribution is a probability distribution over vectors of proportions that sum to one.
  • Disocclusion - Disocclusion is the process by which a previously hidden part of a scene becomes visible when the viewpoint or scene changes.
  • Distance map - A distance map is an image or grid in which each location stores its distance to a specified set of locations, such as the nearest background pixel, object...
  • Distant supervision - Distant supervision creates training signals by connecting unlabeled examples with an external source of information, rather than manually labeling every...
  • Divergence - In vector calculus, divergence measures the local net outward flow of a vector field per unit volume, or per unit area in two dimensions.

Sources

OpenCV, Depth Map from Stereo Images: primary tutorial consulted for the stereo disparity relationship, correspondence estimation, and practical matching limitations. The numerical example and fictional shelf case are original teaching material. https://docs.opencv.org/3.4.18/dd/d53/tutorial_py_depthmap.html

Previous: Disparity Next: Dispersion

  • Home
  • Daily AI Updates
  • Blog
  • AIFBL Academy
  • AI Glossary
  • Products and Tools
  • Store
  • Free CFO AI Prompt Pack
  • About Shihan Sheriff
  • Privacy Policy
  • Terms of Use
  • Refund Policy
  • Cookie Policy
  • Earnings Disclaimer