OPENCV Official Document Learning record (7)

Source: Internet
Author: User

Start today with the official Image Processing section.

Image filtering:

This paper mainly introduces the usage of four kinds of filter functions.

Example code:

1#include <opencv2\opencv.hpp>2#include <iostream>3#include <string>4 5 #pragmaComment (linker, "/subsystem:\" windows\ "/entry:\" Maincrtstartup\ "")6 7 intMax_kernel_length = to;8 9 using namespacestd;Ten using namespaceCV; One  A voidShow (std::stringname,mat img) - { - Namedwindow (name, cv_window_autosize); the imshow (Name, IMG); - } -  - intMainvoid) + { -Mat src = imread ("lena.jpg"); +     if(Src.empty ()) A         return-1; atShow ("SRC", SRC); -  -Mat DST =Src.clone (); -      for(inti =1; i < max_kernel_length; i = i +2) -     { -Blur (SRC, DST, Size (i, I), point (-1, -1)); in     } -Show ("Blur", DST); to  +      for(inti =1; i < max_kernel_length; i = i +2) -     { theGaussianblur (SRC, DST, Size (i, I),0,0); *     } $Show ("Gaussianblur", DST);Panax Notoginseng  -      for(inti =1; i < max_kernel_length; i = i +2) the     { + Medianblur (SRC, DST, i); A     } theShow ("Medianblur", DST); +  -      for(inti =1; i < max_kernel_length; i = i +2) $     { $Bilateralfilter (SRC, DST, I, I *2I2); -     } -Show ("Bilateralfilter", DST); the  - Waitkey ();Wuyi     return 0; the}

You can display the degree of transformation in the following ways:

1#include <opencv2\opencv.hpp>2#include <iostream>3#include <string>4 5 #pragmaComment (linker, "/subsystem:\" windows\ "/entry:\" Maincrtstartup\ "")6 7 intMax_kernel_length = to;8 9 using namespacestd;Ten using namespaceCV; One  A voidShow (std::stringname,mat img) - { - Namedwindow (name, cv_window_autosize); the imshow (Name, IMG); - } -  - intMainvoid) + { -Mat src = imread ("lena.jpg"); +     if(Src.empty ()) A         return-1; atShow ("SRC", SRC); -  -Mat DST =Src.clone (); -      for(inti =1; i < max_kernel_length; i = i +2) -     { -Blur (SRC, DST, Size (i, I), point (-1, -1)); inShow ("Blur", DST); -Waitkey ( -); to     } +  - Waitkey (); the     return 0; *}

Function Description:

Box Filter:

Blur (SRC, DST, Size (i, I), point (-1,-1));

Size (I,i) is the filter's Kernel,point ( -1,-1) is the filter anchor position, which is negative when represented by the kernel of the following filter (which prevents the image from shifting during the transformation process).

Gaussian Filter:

0 0);

The size is also kernel, with the following two parameters being the value of Sigma X, Y, and 0 for following kernel (because it cannot be 0 as the denominator).

Median Filter:

Medianblur (SRC, DST, i);

The parameter I represents the kernel value, because it is a square (two-dimensional) image, so it is good to use only one number, and it needs to be odd.

Bilateral Filter:

2 2);

The following three parameters indicate:

D, the range of diameters to be used for the transformation is that each pixel is calculated according to the surrounding pixels.

Color, colour gamut standard deviation;

Space, the standard deviation of the coordinate spaces.

Although the speed is not good, or upload the converted results Picture it:

The original image went to OpenCV's installation folder to find it.

Above.

OPENCV Official Document Learning record (7)

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.