OPENCV Source Code Analysis (2): Filter Preface 2

Source: Internet
Author: User
OPENCV Source Code Analysis (2): Filter Preface 2

In the last OpenCV source code Analysis of the filter preface 1, according to the Opencv_tutorials.pdf in the filter part of the use of the following 4 kinds of filter used methods. In C + + of OPENCV, these 4 functions are: Blur,gaussianblur,meidablur,bilateralfilter. Here are some of the functions in OpenCV, as well as the parameters: mean filter: Its function is declared as: void Blur (Inputarray src, outputarray DST, Size ksize, point Anchor=point ( -1,-1), int bordertype=border_default).

This function is described in the previous section, which is a bit simpler here.

function: The input image src is filtered with the DST output after the mean value.

parameters:src and DST are, of course, input images and output images respectively. Size is the mean filter template. Anchor is the anchor point (specifically what does not see the source code does not understand), if it is point ( -1,-1), then the anchor point is the center of the filter. Bordertype is an interpolation type for edge points.

Understanding: the image corresponding to the center of the pixel-centered overlap with the template center, the template coverage of all pixels in the domain is the value of the filtered pixels. Gaussian filtering: Its function is declared as: void Gaussianblur (Inputarray src, outputarray DST, Size ksize, double Sigmax, double sigmay=0, int b Ordertype=border_default);

function: The input image src is Gaussian filtered with the DST output.

parameters:src and DST are, of course, input images and output images respectively. Ksize is the Gaussian filter template size, and the Sigmax and Sigmay are Gaussian filters in the horizontal and vertical filter coefficients (somewhat obscure, and so on). Bordertype is an interpolation type for edge points.

Understanding: Digital Image filtering can be easily understood, that is, the original image of each pixel filter, then the corresponding pixel filter value is based on its neighboring pixels (including their own point) and a filter template to multiply. So specifically to Gaussian filtering, we just need to know this Gaussian filter template can be.

Then how to determine the template it. First, the size of this template is ksize, and the calculation of each number is this:

Which is the normalized factor, as it is and is to be 1.

To simplify, typically in two-dimensional image processing, the UI and Uj take 0,sigma1 and Sigma2 equal. So the formula is simplified to:

So it's easy to figure out the number of each position in the template, simple.

But pay attention to 2 points, 1th is ksize width and height must be odd, 2nd is if the parameter sigmax=sigmay=0, then the formula is actually used sigma = 0.3* ((ksize-1) *0.5-1) + 0.8. Median filter: Its function is declared as void Medianblur (Inputarray src, outputarray dst, int ksize).

function: The input image src is median filtered with DST output.

parameters:src and DST are, of course, input images and output images respectively. Ksize is the mean filter template size, because the template is square, so there is only one parameter.

Understanding: with the original image of the pixel-centric overlap with the template center, the template covering the area of all the pixels sorted by the median is the filtered pixel value, so the template length must be odd. bidirectional filtering: Its function is declared as: void Bilateralfilter (Inputarray src, outputarray dst, int D, double sigmacolor, double sigmaspace, I NT Bordertype=border_default)

function: The input image src is bidirectional filtered with DST output.

parameters:src and DST are, of course, input images and output images respectively. D is the diameter of each pixel field, Sigmacolor is the standard deviation of the color space, and sigmaspace is the standard deviation of the coordinate space. Bordertype is an interpolation type for edge points.

Understanding: Temporarily do not understand the two-way filter working principle, there is time to understand and make up again, also welcome you to fill.

Just write it here, enter the formula and the words are exhausted. And write this kind of article how to feel in writing translation document it.

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.