machinevisiontoolbox.ImageSpatial.Kernel.DGauss

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

Derivative 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)

Returns a 2-dimensional derivative of Gaussian kernel with standard deviation sigma

\[\mathbf{K} = \frac{-x}{2\pi \sigma^2} e^{-(x^2 + y^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.DGauss(1)
array([[ 0.0001,  0.0005,  0.0011, -0.    , -0.0011, -0.0005, -0.0001],
       [ 0.0007,  0.0058,  0.0131, -0.    , -0.0131, -0.0058, -0.0007],
       [ 0.0032,  0.0261,  0.0585, -0.    , -0.0585, -0.0261, -0.0032],
       [ 0.0053,  0.0431,  0.0965, -0.    , -0.0965, -0.0431, -0.0053],
       [ 0.0032,  0.0261,  0.0585, -0.    , -0.0585, -0.0261, -0.0032],
       [ 0.0007,  0.0058,  0.0131, -0.    , -0.0131, -0.0058, -0.0007],
       [ 0.0001,  0.0005,  0.0011, -0.    , -0.0011, -0.0005, -0.0001]])
Note:
  • This kernel is the horizontal derivative of the Gaussian, \(dG/dx\).

  • The vertical derivative, \(dG/dy\), is the transpose of this kernel.

  • This kernel is an effective edge detector.

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

Seealso:

Gauss Sobel