machinevisiontoolbox.ImageSpatial.Kernel.Gauss
- static Kernel.Gauss(sigma, h=None)[source]
Gaussian kernel
- Parameters:
sigma (float) – standard deviation of Gaussian kernel
h (integer, optional) – half width of the kernel
- Returns:
Gaussian kernel
- Return type:
ndarray(2h+1, 2h+1)
Return the 2-dimensional Gaussian kernel of standard deviation
sigma
\[\mathbf{K} = \frac{1}{2\pi \sigma^2} e^{-(u^2 + v^2) / 2 \sigma^2}\]The kernel is centred within a square array with side length given by:
\(2 \mbox{ceil}(3 \sigma) + 1\), or
\(2 \mathtt{h} + 1\)
Example:
>>> from machinevisiontoolbox import Kernel >>> K = Kernel.Gauss(sigma=1, h=2) >>> K.shape (5, 5) >>> K array([[0.003 , 0.0133, 0.0219, 0.0133, 0.003 ], [0.0133, 0.0596, 0.0983, 0.0596, 0.0133], [0.0219, 0.0983, 0.1621, 0.0983, 0.0219], [0.0133, 0.0596, 0.0983, 0.0596, 0.0133], [0.003 , 0.0133, 0.0219, 0.0133, 0.003 ]]) >>> K = Kernel.Gauss(sigma=2) >>> K.shape (13, 13)
- Note:
The volume under the Gaussian kernel is one.
If the kernel is strongly truncated, ie. it is non-zero at the edges of the window then the volume will be less than one.
- References:
Robotics, Vision & Control for Python, Section 11.5.1.1, P. Corke, Springer 2023.
- Seealso: