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:
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