pycharmers.opencv.morphology module

pycharmers.opencv.morphology.morph_kernel_creator(shape='erode', ksize=5, 5)[source]

Returns a structuring element of the specified size and shape for morphological operations.

Parameters
  • shape (str, int) – Element shape.

  • ksize (tuple) – Size of the structuring element.

Examples

>>> from pycharmers.opencv import morph_kernel_creator
>>> kernel = morph_kernel_creator(shape="erode", ksize=(5,5))
>>> kernel.shape
(5, 5)
>>> kernel = morph_kernel_creator(shape="erode", ksize=(3,5))
>>> kernel.shape
>>> (5, 3)
pycharmers.opencv.morphology.morph_transformer_creator(op, kernel=None, shape='erode', ksize=5, 5)[source]

Returns a function which performs advanced morphological transformations.

Parameters
  • op (str, int) – Type of a morphological operation

  • kernel (array) – Structuring element. It can be created using morph_kernel_creator The same can be achieved by giving values in the parameters (shape, ksize).

  • shape (str, int) – Element shape.

  • ksize (tuple) – Size of the structuring element.

Examples

>>> from pycharmers.opencv import (SAMPLE_LENA_IMG, morph_transformer_creator,
                                hconcat_resize_min, cv2plot, cv2read_mpl)
>>> img = cv2read_mpl(SAMPLE_LENA_IMG, 0)
>>> transformer = morph_transformer_creator(op="opening", shape="open", ksize=(12,12))
>>> img_opening = transformer(img)
>>> ax = cv2plot(hconcat_resize_min(img, img_opening), cmap="gray")