Morphological Operations

Functions that perform morphological operations on images.

psbeam.morph.get_opening(image, n_erode=1, n_dilate=1, kernel=(5, 5))

Performs the specified number of erosions, followed by the specified number of dilations to get the opening of the image.

Parameters:
  • image (np.ndarray) – The image to perform the opening on. Must be a binary image
  • n_erode (int, optional) – The number of times to perform an erosion on the image.
  • n_dilate (int, optional) – The number of times to perform a dilation on the image.
  • kernel (tuple, optional) – The kernel size to use when eroding and dilating.
Returns:

image_opened – Image that has had n_erode erosions followed by n_dilate dilations.

Return type:

np.ndarray

Raises:

InputError – When image passed is not a binary image

psbeam.morph.get_closing(image, n_erode=1, n_dilate=1, kernel=(5, 5))

Performs the specified number of dilations, followed by the specified number of erosions to get the closing of the image.

Parameters:
  • image (np.ndarray) – The image to perform the closing on.
  • n_erode (int, optional) – The number of times to perform an erosion on the image.
  • n_dilate (int, optional) – The number of times to perform a dilation on the image.
  • kernel (tuple, optional) – The kernel size to use when eroding and dilating.
Returns:

image_opened – Image that has had n_dilate dilations followed by n_erode erosions.

Return type:

np.ndarray

Raises:

InputError – When image passed is not a binary image