machinevisiontoolbox.ImageSpatial.Kernel.Box

static Kernel.Box(h, normalize=True)[source]

Square structuring element

Parameters:
  • h (int) – half-width of kernel

  • normalize (bool, optional) – normalize volume of kernel to one, defaults to True

Returns:

kernel

Return type:

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

Returns a square kernel with unit volume.

The kernel is centred within a square array with side length given by \(2\mathtt{h} + 1\).

Example:

>>> from machinevisiontoolbox import Kernel
>>> Kernel.Box(2)
array([[0.04, 0.04, 0.04, 0.04, 0.04],
       [0.04, 0.04, 0.04, 0.04, 0.04],
       [0.04, 0.04, 0.04, 0.04, 0.04],
       [0.04, 0.04, 0.04, 0.04, 0.04],
       [0.04, 0.04, 0.04, 0.04, 0.04]])
>>> Kernel.Box(2, normalize=False)
array([[1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1.],
       [1., 1., 1., 1., 1.]])
References:
  • Robotics, Vision & Control for Python, Section 11.5.1.1, P. Corke, Springer 2023.

Seealso:

Circle