Blur, gaussianblur, medianblur, and bilateralfilter for opencv2 Function Learning: smooth image processing

Source: Internet
Author: User

In opencv2, Blur may be used to smooth the image. This method is the simplest way to calculate the mean.

  • SmoothAlso knownFuzzyIs a simple and frequently used image processing method.

  • Smooth Processing has many functions, but in many places we only focus on its noise reduction function.

  • OneFilter. The most common filter isLinearFilter.

void blur( const Mat& src, Mat& dst,Size ksize, Point anchor=Point(-1,-1),int borderType=BORDER_DEFAULT );

Parameters:

SRC: original image.

DST: target image.

Ksize: defines the size of the filter. Such as size (3, 3 ).

Anchor: Specifies the anchor position (smoothing point). If it is a negative value, the center of the core is the anchor. Omitted

Bordertype: used to infer edge pixels. Generally, the default value is border_default. Omitted

Example:

blur(src,dst,Size(3,3));

 

The opencv2 function gaussianblur performs Gaussian smoothing. Gaussian filtering is used to combine each pixel of the input arrayGaussian KernelConvolution: convolution and is used as the output pixel value.

void GaussianBlur( const Mat& src, Mat& dst, Size ksize,double sigmaX, double sigmaY=0,int borderType=BORDER_DEFAULT );

Parameters:

Sigmax: standard variance in the X direction. It can be set to 0 for Automatic Calculation by the system.

Sigmay: standard variance in the Y direction. It can be set to 0 for Automatic Calculation by the system.

Example:

GaussianBlur(src,dst,Size(9,9),0,0);

 

The opencv2 function medianblur performs the medianblur filtering operation. The medicv2 function filters the pixels of each pixel in the image using the neighborhood (the square area centered on the current pixel ).Median.

void medianBlur( const Mat& src, Mat& dst, int ksize );

The opencv2 function bilateralfilter performs bilateral filtering. Similar to Gaussian filter, a bilateral filter also assigns a weighting factor to each neighboring pixel. These weighting coefficients consist of two parts. The first part of the weighting method is the same as Gaussian filtering, and the second part of the weight is determined by the gray difference between the neighboring pixel and the current pixel.

void bilateralFilter( const Mat& src, Mat& dst, int d,double sigmaColor, double sigmaSpace,int borderType=BORDER_DEFAULT );

Parameters:

D: the diameter of the pixel's neighborhood.

Sigmacolor: standard variance of the color space.

Sigmaspace: standard variance (pixel unit) of the coordinate space ).

Example:

bilateralFilter ( src, dst, i, i*2, i/2 );

 

......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.