binary2contours

tomni.transformers.binary2contours(binary_img: numpy.ndarray, return_inner_contours: bool = True) List[numpy.ndarray][source]

Convert a binary image to a list of outer contours and their corresponding inner contours if ‘return_inner_contours’ is True. If ‘return_inner_contours’ is False, only outer contours are returned.

Parameters
  • binary_img (np.ndarray) – A binary image.

  • return_inner_contours (bool) – boolean to check if inner contours are desired. Defaults to True.

Returns

A list of outer contours with their corresponding inner contours.

Return type

List[np.ndarray]