Image.morph#

Image.morph(se: ndarray | list, op: str, n: int = 1, border: str = 'replicate', bordervalue: float = 0, **kwargs: Any) Self[source]#

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.

The image can be of any type and boolean images where True is treated as 1 and False as 0. The structuring element should be a 2D array of non-negative integers, where non-zero values indicate the shape of the structuring element.

'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 structuring 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:

Important

Uses OpenCV function cv2.morphologyEx which accepts multiple-channel, CV_8U, CV_16U, CV_16S, CV_32F or CV_64F images.

Seealso:

erode dilate open close opencv.morphologyEx