Lulumoy Studio

Math guide

Gaussian blur

Weighted average of the neighbours using a Gaussian bell: it attenuates noise and fine detail, giving more weight near the centre.

G(x,y)=12πσ2e−x2+y22σ2
Two-dimensional Gaussian kernel.
I′(x,y)=∑i=−rr∑j=−rrG(i,j)·I(x+i,y+j),r=k−12
The kernel is truncated to k×k and normalised so its weights add up to 1, so the mean brightness does not change. It is separable: OpenCV applies it as two one-dimensional filters.
σ=0.3(k−12−1)+0.8
Sigma used by OpenCV when it is left at 0 (automatic).

Parameters

ParameterMeaning
Kernel size (odd)k, side of the kernel. It must be odd: an even value is raised to the next odd one. With a fixed sigma, k ≈ 6σ + 1 avoids truncating the bell.
Sigma (0 = automatic)σ in pixels: the larger, the stronger the blur. 0 = computed from k.

References

  1. OpenCV 4.x documentation — Image Filtering (GaussianBlur, blur, medianBlur, bilateralFilter, morphologyEx). docs.opencv.org/4.x/d4/d86/group__imgproc__filter.html
  2. R. C. Gonzalez, R. E. Woods. Digital Image Processing, 4th ed. Pearson, 2018.
  3. R. Szeliski. Computer Vision: Algorithms and Applications, 2nd ed. Springer, 2022. szeliski.org/Book/