OpenCv 026 --- bilateral Gaussian filter

1 prepared before knowledge

  Previous image convolution processing either mean or Gaussian blur convolution belong, then they have a common feature is the fuzzy image edge information disappeared or been destroyed. Goss bilateral filtering can be achieved by convolution processing to reduce image blurring image edge damage while the output of the full image after the filter holds the overall edge (outline) information, we call this type of filtering algorithm for the edge-preserving filtering algorithm (EPF). The most common edge-preserving filtering algorithm are the following:

- Bilateral Gaussian Blur: Gaussian blur image is to consider the impact of spatial location of weight, but it does not take effect on the distribution of the image pixels of the output image convolution, bilateral blur considering the effect of the distribution of pixel values, the pixel values ​​are quite different spatial distribution It is retained in order to retain the integrity of the image edge information.

- Meanshift mean migration blur: TODO

- Locally variance fuzzy: TODO

- OpenCV of the edge-preserving filter and a specialized API: below

2 used mainly OpenCv API

/** @brief Applies the bilateral filter to an image.
The function applies bilateral filtering to the input image, as described in
http://www.dai.ed.ac.uk/CVonline/LOCAL_COPIES/MANDUCHI1/Bilateral_Filtering.html
bilateralFilter can reduce unwanted noise very well while keeping edges fairly sharp. However, it is
very slow compared to most filters.
_Sigma values_: For simplicity, you can set the 2 sigma values to be the same. If they are small (\<
10), the filter will not have much effect, whereas if they are large (\> 150), they will have a very
strong effect, making the image look "cartoonish".
_Filter size_: Large filters (d \> 5) are very slow, so it is recommended to use d=5 for real-time
applications, and perhaps d=9 for offline applications that need heavy noise filtering.
This filter does not work inplace.
@param src Source 8-bit or floating-point, 1-channel or 3-channel image.
@param dst Destination image of the same size and type as src .
@param d Diameter of each pixel neighborhood that is used during filtering. If it is non-positive,
it is computed from sigmaSpace.
@param sigmaColor Filter sigma in the color space. A larger value of the parameter means that
farther colors within the pixel neighborhood (see sigmaSpace) will be mixed together, resulting
in larger areas of semi-equal color.
@param sigmaSpace Filter sigma in the coordinate space. A larger value of the parameter means that
farther pixels will influence each other as long as their colors are close enough (see sigmaColor
). When d\>0, it specifies the neighborhood size regardless of sigmaSpace. Otherwise, d is
proportional to sigmaSpace.
@param borderType border mode used to extrapolate pixels outside of the image, see #BorderTypes
 */
CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d,
                                   double sigmaColor, double sigmaSpace,
                                   int borderType = BORDER_DEFAULT );

3 program code

#include <opencv2/opencv.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main ( int parte, char ** argv) {
    Mat src = imread("images/Demo.jpg");
    if (src.empty()) {
        printf("could not load image...\n");
        return -1;
    }
    namedWindow("input", CV_WINDOW_AUTOSIZE);
    imshow("input", src);

    Mat dst;
    bilateralFilter(src, dst, 0, 100, 10, 4);
    imshow("result", dst);

    waitKey(0);
    return 0;
}

4 run results

slightly

5 Expansion and precautions

none

6 * Currently only probably understand, know this algorithm, subsequent detailed analysis of the specific use to do

Guess you like

Origin www.cnblogs.com/Vince-Wu/p/11846886.html