# WLS filtering

Hello everyone,

I have been using stereoSGBM algorithm to compute a disparity map. The result is okay, but too noisy. In order to get a better result, I have used the WLS (weighted least square) filtering algorithm provided by OpenCV and followed the example given by them here . However, the example doesn't explain the algorithm at all and i got really poor results. Even if the contours are better defined after applying the filter, and the smoothing inside the differents object is better, I have this huge problem with the gray levels that doesn't stay stable and that doesn't stay the same even if nothing moves in the image. For examples, see below where you can see 3 images (on the left is the original frame, in the middle is the disparity map computed with SGBM algorithm and on the right there is the disparity map given after WLS filtering). As you can see, the gray level change tremendously between to frame and they are not stable at all.

1st frame taken :

2nd frame taken (just after the 1st one, nothing has moved in the image) :

Has anyone worked with the WLS filter for the disparity map or has anyone an idea on how I can correct this problem ?

Many thanks.

edit retag close merge delete

The exposure/gain/wb looks different. If you have a static scene and a static camera, you can temporally filter your results, otherwise, you might want to look into quantifying the uncertainty for each pixel. Look at the source of DisparityWLSFilter and see that it boils down to about 4 lines of code. Consider improving upon this using the confidence/uncertainty of each pixel. As a start, SGBM will give you a confidence image with a left and right matcher.