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)