Gaussian filtering OpenCV

Theoretical Analysis of Gaussian filtering
Gaussian smoothing filter is a linear, Gaussian noise can be eliminated, a noise reduction process is widely used in image processing. Gaussian filtering is performed on the whole image process of the weighted average value of each pixel, and the other by its own neighborhood pixel values obtained after a weighted average. Specific operation Gaussian filter is: a template (or become a convolution mask) scanning each pixel in the image, the weighted average of the gray pixels in the neighborhood determined by the value of the template to replace the central pixel of the template.
Gaussian blurred image generation technique, visual effect is like a translucent screen image through the observation, that the lens-focus imaging Bokeh general lighting and shadow effects are significantly different. Gaussian smoothing is also used in the pretreatment stage of computer vision algorithms to enhance the image effect image at different scales. From a mathematical point of view, Gaussian blur process image is the image and do normal convolution. Since the normal distribution also known as Gaussian distribution, so the technology is called Gaussian blur.
Fuzzy circular image block convolve produces a more accurate bokeh. Since the Fourier transform of the Gaussian function is a Gaussian function Further, the Gaussian blur for the image is a low-pass filtering operation.

2. The calculation principle
① Gaussian function
Here Insert Picture Description
② to 3 * 3 template, for example
to the central location of the template sample the origin of coordinates. Coordinates of each position in the template, as shown below (x-axis horizontally to the right, y axis vertically upward).
Here Insert Picture Description
Then substituting the coordinates of the Gaussian function, is calculated as follows:
Here Insert Picture Description
order was:
Here Insert Picture Description

3. Gaussian filter: GaussianBlur function

C++:void GaussianBlur(InputArray src,OutputArray dst,Size ksize,double sigmaX,double sigmaY=0,intborderType=BORDER_DEFAULT)
第一个参数:src,输入图像,图像深度应该为CV_8U、CV_16U、CV_16S、CV_32F、CV_64F之一
第二个参数:dst,处理后结果图像
第三个参数:Size类型的ksize高斯核大小。其中ksize.width、ksize.height可以不同,但都必须为正奇数。
第四个参数:double类型的sigmaX,表示高斯核函数在X方向的标准差偏差。
第五个参数:double类型的sigmaY,表示高斯核函数在Y方向的标准差偏差。若将其设为0,就将它设为sigmaX;如果sigmaX和sigmaY都是0,那么就由ksize.width、ksize.height计算出来。
第六个参数:int类型的borderType,用于推断图像外部像素的某种边界模式,一般不去管它。

4. Case

void Gauss()
{
	Mat src = imread("img.jpg", 0);
	Mat dst;

	namedWindow("原图", 0);
	imshow("原图", src);

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

	namedWindow("高斯处理图", 0);
	imshow("高斯处理图", dst);
}

Here Insert Picture Description

Released eight original articles · won praise 0 · Views 77

Guess you like

Origin blog.csdn.net/ETNthrough/article/details/103998662