Computes and returns the ksize x 1
matrix of Gaussian filter coefficients.
cv2.getGaussianKernel(ksize, sigma[, ktype]) → retval
ksize
as sigma = 0.3*(0.5*(ksize – 1)-1)+0.8
.cv2.CV_*
): Type of filter coefficients. May be cv2.CV_32F
or cv2.CV_64F
(default).This function computes and returns the ksize x 1 matrix of Gaussian filter coefficients:
\[G_i\ =\ \alpha\ *\ e^\frac{-\left(i-(ksize-1))/2\right)^2}{2*{\rm sigma}^2}\]Where \(i= 0…ksize-1\) and \(\alpha\) is the scaling factor so that \(\sum_{i} G_i=1 \).
sepFilter2D()
or to createSeparableLinearFilter()
. Those functions automatically recognize smoothing kernels (symmetrical kernels with sum of weights equal to 1) and handle them accordingly. GaussianBlur()
.