Reputation: 13136
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
Upvotes: 1
Views: 1865
Reputation: 1620
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.
OpenCV has this built-in: http://docs.opencv.org/modules/imgproc/doc/filtering.html?highlight=bilateralfilter#bilateralfilter
Upvotes: 1