colour_checker_detection.detection.remove_stacked_contours#

colour_checker_detection.detection.remove_stacked_contours(contours: ArrayLike, keep_smallest: bool = True) Tuple[NDArrayInt, ...][source]#

Remove amd filter out the stacked contours from given contours keeping either the smallest or the largest ones.

Parameters:
  • contours (ArrayLike) – Stacked contours to filter.

  • keep_smallest (bool) – Whether to keep the smallest contours.

Returns:

Filtered contours.

Return type:

tuple

References

[Wal22]

Examples

>>> contours = np.array(
...     [
...         [[0, 0], [7, 0], [7, 7], [0, 7]],
...         [[0, 0], [8, 0], [8, 8], [0, 8]],
...         [[0, 0], [10, 0], [10, 10], [0, 10]],
...     ]
... )
>>> remove_stacked_contours(contours)  
(array([[0, 0],
       [7, 0],
       [7, 7],
       [0, 7]]...)
>>> remove_stacked_contours(contours, False)  
(array([[ 0,  0],
       [10,  0],
       [10, 10],
       [ 0, 10]]...)