machinevisiontoolbox.ImageSpatial.Kernel.DoG

static Kernel.DoG(sigma1, sigma2=None, h=None)[source]

Difference of Gaussians kernel

Parameters:
  • sigma1 (float) – standard deviation of first Gaussian kernel

  • sigma2 (float, optional) – standard deviation of second Gaussian kernel

  • h (int, optional) – half-width of Gaussian kernel

Returns:

difference of Gaussian kernel

Return type:

ndarray(2h+1, 2h+1)

Return the 2-dimensional difference of Gaussian kernel defined by two standard deviation values:

\[\mathbf{K} = G(\sigma_1) - G(\sigma_2)\]

where \(\sigma_1 > \sigma_2\). By default, \(\sigma_2 = 1.6 \sigma_1\).

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
>>> Kernel.DoG(1)
array([[ 0.0019,  0.0049,  0.0082,  0.0095,  0.0082,  0.0049,  0.0019],
       [ 0.0049,  0.0108,  0.0116,  0.0085,  0.0116,  0.0108,  0.0049],
       [ 0.0082,  0.0116, -0.0142, -0.0427, -0.0142,  0.0116,  0.0082],
       [ 0.0095,  0.0085, -0.0427, -0.0937, -0.0427,  0.0085,  0.0095],
       [ 0.0082,  0.0116, -0.0142, -0.0427, -0.0142,  0.0116,  0.0082],
       [ 0.0049,  0.0108,  0.0116,  0.0085,  0.0116,  0.0108,  0.0049],
       [ 0.0019,  0.0049,  0.0082,  0.0095,  0.0082,  0.0049,  0.0019]])
Note:
  • This kernel is similar to the Laplacian of Gaussian and is often used as an efficient approximation.

  • This is a “Mexican hat” shaped kernel

References:
  • Robotics, Vision & Control for Python, Section 11.5.1.3, P. Corke, Springer 2023.

Seealso:

LoG Gauss