1

Is there any algorithm, which can remove outliers, but do not blur other part of image?

Only for example, when we use cv::StereoBM/SBGM or cv::gpu::StereoConstantSpaceBP from opencv, then we can have outliers, as shown in relevant question: opencv sgbm produces outliers on object edges Also, we can get large bursts of intensity (strong variations) in local area of image with similar colors: enter image description here

And many other cases...

The simplest solution is using cv::medianBlur(), but it will smooth all image, not only outliers: Median filter example video

Is there any algorithm which smoothes only outliers, and It does not affect the rest of the image?

Is there anything better than this?

// get cv::Mat src_frame ...
int outliers_size = 10;
int outliers_intensive = 100;
int ksize = outliers_size*2 + 1; // smooth all outliers smaller than 11x11
cv::Mat smoothed;
cv::medianBlur( src_frame, smoothed, ksize  );
cv::Mat diff;
cv::absdiff( src_frame, smoothed, diff );
cv::Mat mask = diff > Scalar( outliers_intensive );

smoothed.copyTo( src_frame, mask );
// we have smoothed only small outliers areas in src_frame
Community
  • 1
  • 1
Alex
  • 12,578
  • 15
  • 99
  • 195

1 Answers1

1

Perhaps you are looking for the bilateral filter?

OpenCV says:

we have explained some filters which main goal is to smooth an input image. However, sometimes the filters do not only dissolve the noise, but also smooth away the edges. To avoid this (at certain extent at least), we can use a bilateral filter.

Here's what it looks like on a depth image

OpenCV has this built-in: http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=bilateralfilter#bilateralfilter

Community
  • 1
  • 1
Adam Finley
  • 1,550
  • 1
  • 16
  • 28
  • Thank you. Yes, I looked for the bilateral filter and especially for the `cv::gpu::DisparityBilateralFilter`: http://docs.opencv.org/modules/gpu/doc/camera_calibration_and_3d_reconstruction.html#gpu::DisparityBilateralFilter But as you shown on your picture - bilateral filter: 1. don't removes outliers - result image has still the same outliers, 2. it smoothes all image exclude edges. I need remove outliers and minimize affect to other part of image. – Alex Jun 17 '15 at 18:28