machinevisiontoolbox.ImageSpatial.Kernel.Gauss

classmethod 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:

2h+1 x 2h+1 Gaussian kernel

Return type:

Kernel

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)
>>> print(K)
Kernel: 5x5, min=0.003, max=0.16, mean=0.04, SYMMETRIC (Gaussian σ=1)
>>> K.print()
 0.00 0.01 0.02 0.01 0.00
 0.01 0.06 0.10 0.06 0.01
 0.02 0.10 0.16 0.10 0.02
 0.01 0.06 0.10 0.06 0.01
 0.00 0.01 0.02 0.01 0.00
>>> 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:

DGauss