machinevisiontoolbox.ImageSpatial.Kernel.Circle

classmethod Kernel.Circle(radius, h=None, normalize=False, dtype='uint8')[source]

Circular structuring element

Parameters:
  • radius (scalar, array_like(2)) – radius of circular structuring element

  • h (int) – half-width of kernel

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

  • dtype (str or NumPy dtype, optional) – data type for image, defaults to uint8

Returns:

2h+1 x 2h+1 circular kernel

Return type:

Kernel

Returns a circular kernel of radius radius pixels. Sometimes referred to as a tophat kernel. Values inside the circle are set to one, outside are set to zero.

If radius is a 2-element vector the result is an annulus of ones, and the two numbers are interpretted as inner and outer radii respectively.

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

Example:

>>> from machinevisiontoolbox import Kernel
>>> Kernel.Circle(2)
<machinevisiontoolbox.ImageSpatial.Kernel object at 0x7f1b3a3152b0>
>>> Kernel.Circle([2, 3])
<machinevisiontoolbox.ImageSpatial.Kernel object at 0x7f1b3a328b20>
References:
  • Robotics, Vision & Control for Python, Section 11.5.1.1, P. Corke, Springer 2023.

Seealso:

Box