I just started with Kitty Stereo Dataset (2015). The first thing I did was compute the disparity using the stereoSGBM class. And here is the rectified input images and the disparity output from the application of stereoSGBM: enter image description here

enter image description here

As the colorbar indicates, the raw disparity values in the disparity image go from 0 -> 1000. I didn't expect such high values of disparity. How do I interpret these disparity values?

Further, to fill holes in the disparity map, I used cv.ximgproc.createDisparityWLSFilter object. And I get the filtered disparity:

enter image description here

The filtered disparity again has high values in range of ~1000. How to make sense of these disparity values? How do I obtain the correct disparity values (in pixels) ?


1 Answer 1


Looking into the documentation of StereoSGBM I found the following explaination link.

enter image description here

It says: Some algorithms, like StereoBM or StereoSGBM compute 16-bit fixed point disparity map (where each disparity value has 4 fractional bits).

So, I simply applied 4 right shifts to drop the fractional part using numpy.right_shift() and I get some sensible disparity values. enter image description here

Note that ideally, one should not throw away the 4 fractional bits.

  • 1
    $\begingroup$ I was going to ask what the units were on that disparity, but glad you found the answer! You can also accept your own answer so other users can find solutions in the future :D $\endgroup$
    – Chuck
    Jun 28, 2023 at 15:09
  • $\begingroup$ That's great, thanks for the reply... it would be great to know WHY this output format was chosen!! $\endgroup$
    – EdwardAndo
    Oct 9, 2023 at 12:38
  • $\begingroup$ @EdwardAndo The documentation does not tell much, but I think this particular format is memory efficient and disparity computation results from block matching do not produce very fine disparity changes (4 bits will capture only about 16 fractional levels). $\endgroup$
    – vyi
    Oct 9, 2023 at 13:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.