imgcv.connectivity.connected_components

Functions

check_image(image)

Check if the input is a numpy array

connected_component_analysis(im)

Peforms connected component analysis on a binary image. Currently only 4-connected component analysis is supported.

_is_binary(im)

Checks if the image is binary or not. A binary image is an image that has only two pixel values. For example, 0 and 1.

Module Contents

imgcv.connectivity.connected_components.check_image(image)

Check if the input is a numpy array

Parameters:

image (np.ndarray) – Input image to be transformed

Raises:
  • TypeError – If the input is not a numpy array

  • ValueError – If the input is not a grayscale or color image

imgcv.connectivity.connected_components.connected_component_analysis(im)

Peforms connected component analysis on a binary image. Currently only 4-connected component analysis is supported.

NOTE: The input image should be a binary image. Non-zero pixels are considered as foreground. This function will not work properly if the input image is not binary.

Parameters:

im (np.ndarray) – Binary image. Non-zero pixels are considered as foreground

Raises:

ValueError – If the input image is not binary

Returns:

Image with connected components labeled. Each connected component will have a unique label int: Number of connected components in the image

Return type:

np.ndarray

imgcv.connectivity.connected_components._is_binary(im)

Checks if the image is binary or not. A binary image is an image that has only two pixel values. For example, 0 and 1.

Returns:

True if the image is binary, False otherwise

Return type:

Boolean