machinevisiontoolbox.Image.morph

Image.morph(se, op, n=1, border='replicate', bordervalue=0, **kwargs)

Morphological neighbourhood processing

Parameters:
  • se (ndarray(N,M)) – structuring element

  • op (str) – morphological operation, one of: ‘min’, ‘max’, ‘diff’

  • n (int, optional) – number of times to apply the operation, defaults to 1

  • border (str, optional) – option for boundary handling, see ve, defaults to ‘replicate’

  • bordervalue (scalar, optional) – padding value, defaults to 0

  • kwargs – addition options passed to opencv.morphologyEx

Returns:

morphologically transformed image

Return type:

Image

Apply the morphological operation oper with structuring element se to the image n times.

'oper'

description

'min'

minimum value over the structuring element

'max'

maximum value over the structuring element

'diff'

maximum - minimum value over the structuring element

Note:
  • It is cheaper to apply a smaller structuring element multiple times than one large one, the effective structuing element is the Minkowski sum of the structuring element with itself N times.

  • Performs greyscale morphology

  • The structuring element should have an odd side length.

  • For a binary image, min = erosion, max = dilation.

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

Seealso:

erode dilate opencv.morphologyEx