Ask Your Question

How to increase the quality of Disparity Map?

asked 2013-03-18 03:02:59 -0500

I am working on stereo images. After doing camera calibration and everything, I am trying to get a depth image. But depth image depends on the disparity map and I am not getting proper disparity map.

Here is a screenshot of my Disparity Map. (It shows only one image, but I have two images from two diff webcams separated by around 3cms)

image description

I am using StereoBM and following are the values that I have set.

StereoBM sbm;
sbm.state->SADWindowSize = 25;
sbm.state->numberOfDisparities = 64;
sbm.state->preFilterSize = 27;
sbm.state->preFilterCap = 63;
sbm.state->minDisparity = 0;
sbm.state->textureThreshold = 20;
sbm.state->uniquenessRatio = 9;
sbm.state->speckleWindowSize = 0;
sbm.state->speckleRange = 4;

I want Disparity Map generation to be real time. Graph Cut algorithm seems to take a lot of time. Is there any method by which I can increase the quality of Disparity Map?

edit retag flag offensive close merge delete


Martin Peris has a neat tool to adjust the states for the block method:

Ralph058 gravatar imageRalph058 ( 2013-03-18 06:46:14 -0500 )edit

Actually, I have used that program to get these values. But can't figure out how to get better quality.

jayrambhia gravatar imagejayrambhia ( 2013-03-18 07:25:25 -0500 )edit

As a guess, I would use a lower window size and fewer disparities. The larger the window size, the fewer fine details. I use 5 to keep the processor time to a minimum and 7 looks a little better, but after that, it looks worse. The algorithm doesn't seem to work well if the number of disparities gets too high, in some cases.It will work better if you set the minimum number of disparities near the disparity at the range of your closest subject (it will be non-zero). There is a simple formula out there to calculate the disparity, but most authors want to get too esoteric. Solving this guy's range equation for disparity will work.

I think that the texture threshold looks too high. I will give you my numbers when I get to the office.

Ralph058 gravatar imageRalph058 ( 2013-03-18 10:02:32 -0500 )edit

@jayrambhia, did you end up finding a way to get better quality out of the disparity map?

lazd gravatar imagelazd ( 2013-05-31 16:53:36 -0500 )edit

yeah. I have added those parameters here.

jayrambhia gravatar imagejayrambhia ( 2013-06-02 05:31:56 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2013-03-18 14:32:22 -0500

Ralph058 gravatar image

updated 2016-09-22 09:04:28 -0500

StereoBM sbm;
sbm.state->SADWindowSize = 5;
sbm.state->numberOfDisparities = 112;  //large baseline
sbm.state->preFilterSize = 5;
sbm.state->preFilterCap = 61;
sbm.state->minDisparity = -39;          // large (30cm) baseline and 36 pixel offset toward
                                        // centerline on each camera (72 pixel preset disparity)
sbm.state->textureThreshold = 507; //there appear to be multiple minima with this function
sbm.state->uniquenessRatio = 0;    //I used 5 with good results with other settings above
sbm.state->speckleWindowSize = 0;  //I used 2 ""
sbm.state->speckleRange = 1;       //I used 9 ""
edit flag offensive delete link more


Hello, I can't find a documentation explaining how to choose the correct values to insert in each variable. Can someone please help me?

Lu gravatar imageLu ( 2016-09-22 16:33:01 -0500 )edit

I'm looking for it too

torugo gravatar imagetorugo ( 2017-10-04 14:11:31 -0500 )edit

Question Tools



Asked: 2013-03-18 03:02:59 -0500

Seen: 12,342 times

Last updated: Sep 22 '16