machinevisiontoolbox.ImageSpatial.Kernel.LoG

static Kernel.LoG(sigma, h=None)[source]

Laplacian of Gaussian kernel

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

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

Returns:

kernel

Return type:

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

Return a 2-dimensional Laplacian of Gaussian kernel with standard deviation sigma

\[\mathbf{K} = \frac{1}{\pi \sigma^4} \left(\frac{u^2 + v^2}{2 \sigma^2} -1\right) 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
>>> Kernel.LoG(1)
array([[ 0.0005,  0.0028,  0.0087,  0.0125,  0.0087,  0.0028,  0.0005],
       [ 0.0028,  0.0177,  0.0394,  0.0432,  0.0394,  0.0177,  0.0028],
       [ 0.0087,  0.0394,  0.0002, -0.0964,  0.0002,  0.0394,  0.0087],
       [ 0.0125,  0.0432, -0.0964, -0.3181, -0.0964,  0.0432,  0.0125],
       [ 0.0087,  0.0394,  0.0002, -0.0964,  0.0002,  0.0394,  0.0087],
       [ 0.0028,  0.0177,  0.0394,  0.0432,  0.0394,  0.0177,  0.0028],
       [ 0.0005,  0.0028,  0.0087,  0.0125,  0.0087,  0.0028,  0.0005]])
Note:

This is the classic “Mexican hat” shaped kernel

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

Seealso:

Laplace DoG Gauss zerocross