AI Glossary / Graphs and symbolic AI / Intermediate

Disparity

Definition

Disparity, in stereo vision, is the difference between the image positions of corresponding scene points in two views. For a calibrated and rectified stereo pair, it is commonly measured as a horizontal pixel displacement. Disparity provides a geometric cue for estimating depth: under the standard aligned-camera model, larger disparity corresponds to a nearer point.

What it means

Two cameras view a scene from slightly different positions. The same object point usually appears at different horizontal coordinates in the two images. Finding the corresponding points reveals their disparity, and known camera geometry connects that shift to distance.
The term is not the same as a difference in brightness or color between arbitrary pixels. It requires a correspondence: the two image points should represent the same physical point. This article uses the stereo-vision meaning, rather than disparity as a general social, statistical, or performance difference.

How it works

Calibrate the camera pair to estimate its geometry and correct relevant distortion. Rectification transforms the images so corresponding points lie on aligned scan lines in the standard setup. A stereo-matching method searches for plausible correspondences and estimates their horizontal displacements.
For an ideal rectified pair with aligned principal-point convention, depth Z is f times B divided by disparity d, where f is focal length in pixels and B is the camera baseline in distance units. More general calibrated setups use their projection geometry or a reprojection matrix. A dense disparity map assigns estimates across an image, but occluded, textureless, or repetitive regions may have invalid or uncertain matches.

Three practical examples

  • A robot uses calibrated stereo images to estimate the positions of visible obstacles, while accounting for uncertain or missing depth.
  • A measurement prototype compares corresponding points in two views to reconstruct a scene in three dimensions.
  • A vision evaluation examines disparity errors separately near object boundaries, where occlusions and mixed image regions make matching difficult.

Think of it this way

Hold a finger in front of you and alternate which eye is open. Its apparent position shifts relative to the background because the viewpoints differ. The analogy makes disparity intuitive, but a camera system needs numerical calibration and correspondence estimates. Human depth perception also uses cues beyond stereo disparity.

Worked example

Assume a rectified stereo pair with focal length f = 800 pixels and baseline B = 0.12 meters, using the simple model Z = fB/d. A matched point appears at horizontal coordinate 420 in the left image and 396 in the right. With disparity defined as left minus right, d = 24 pixels. Depth is 800 times 0.12 divided by 24, or 4 meters.
For a point with disparity 12 pixels, the same calculation gives 8 meters. Halving disparity doubles depth under these assumptions. If the first disparity were estimated as 23 rather than 24 pixels, the calculated depth would be 96/23, about 4.174 meters, an error of about 0.174 meters. At disparity 12, estimating 11 gives about 8.727 meters, a larger error of about 0.727 meters.
The comparison shows why an equal pixel error can produce a larger depth error for distant points. These values assume correct calibration and true correspondences; they do not describe the accuracy of a particular camera.

Illustrative case study

At fictional Cedar Vision, a team tests a stereo prototype on patterned boxes and a plain wall. The box regions produce plausible correspondences, while parts of the wall have little visual texture. An early display colors every estimated pixel as though it were equally reliable.
The team changes the evaluation and display to distinguish valid estimates from uncertain or invalid matches. This fictional case illustrates interpreting a disparity map. It does not report a measured improvement or claim that a visually smooth map is a reliable reconstruction.

Common misconceptions and mistakes

Disparity is not depth itself, and its scale is not interchangeable with meters. Pixel focal length and pixel disparity must use consistent image scaling. If images are resized, the geometry must be updated accordingly.
A value of zero should not casually be treated as a valid finite depth: in the ideal formula it corresponds to unbounded distance, but software may also use special values to indicate failed matching. Sign and invalid-value conventions vary. Do not assume the same physical point is visible in both cameras; occlusion can make correspondence impossible. Finally, learned stereo matching can improve estimates but does not remove calibration and uncertainty requirements.

Business use

Businesses using stereo measurements should validate depth over the intended range, surfaces, lighting, and motion conditions. Report invalid regions and uncertainty rather than only an attractive color map. Preserve camera calibration, image resolution, baseline units, and the disparity representation used by the software. When a downstream decision depends on distance, evaluate the resulting distance errors as well as average disparity error, since the geometric conversion changes their practical impact.

People also ask

Does larger disparity always mean nearer?

Under the specified standard rectified stereo geometry and sign convention, yes; arbitrary camera arrangements require the proper calibration model.

Can every pixel have a reliable match?

No. Occlusions, weak texture, reflections, and repeated patterns can make matches absent or ambiguous.

Is disparity measured only in whole pixels?

No. Algorithms can estimate subpixel displacement, although numerical precision alone does not establish accuracy.

Check your understanding

With the same focal length and baseline, what happens when disparity changes from 24 to 12 pixels?

Answer: Depth doubles from 4 to 8 meters in the stated model because depth is inversely proportional to disparity.

Related terms

  • Rectification
  • Baseline
  • Depth map
  • Epipolar geometry
  • Stereo vision
  • correspondence
  • camera calibration
  • triangulation
  • occlusion
  • reprojection

Learn next

Learn epipolar geometry next to understand why rectification simplifies matching. Then distinguish a missing correspondence from a noisy one and trace how each should be handled before a depth estimate reaches a decision system.

  • Epipolar geometry
  • Rectification

More in Graphs and symbolic AI

  • Discrete events - In knowledge representation, discrete events are occurrences with a definite structure and identifiable boundaries.
  • Discretization - Discretization represents a continuous quantity or space using a set of distinct values, categories, intervals, or grid points.
  • Disjunctive constraint - A disjunctive constraint requires at least one of several alternative conditions to hold. Its logical form is an OR between constraints.
  • Dispersion - Dispersion, in the network-analysis sense used here, measures how separated the mutual neighbors of two connected nodes are from one another.
  • Distance-Regular Graphs - Distance-regular graphs are connected graphs whose local connection counts around pairs of vertices depend on their graph distance rather than on the...
  • Distributed constraint satisfaction - Distributed constraint satisfaction is a way of solving a constraint problem in which variables, constraints, or decision responsibilities are distributed...

Sources

Primary source: OpenCV official Depth Map from Stereo Images tutorial, https://docs.opencv.org/4.x/dd/d53/tutorial_py_depthmap.html ; official stereo correspondence and reprojection documentation, https://docs.opencv.org/5.0/main_modules/stereo.html . The camera geometry calculations and fictional case are original teaching illustrations.

Previous: Disparate treatment Next: Disparity map

  • 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