colour_checker_detection.detection.approximate_contour#

colour_checker_detection.detection.approximate_contour(contour: ArrayLike, points: int = 4, iterations: int = 100) NDArrayInt[source]#

Approximate given contour to have given number of points.

The process uses binary search to find the best epsilon value producing a contour approximation with exactly points.

Parameters:
  • contour (ArrayLike) – Contour to approximate.

  • points (int) – Number of points to approximate the contour to.

  • iterations (int) – Maximal number of iterations to perform to approximate the contour.

Returns:

Approximated contour.

Return type:

numpy.ndarray

References

[Olf19]

Examples

>>> contour = np.array([[0, 0], [1, 0], [1, 1], [1, 2], [0, 1]])
>>> approximate_contour(contour, 4)  
array([[0, 0],
       [1, 0],
       [1, 2],
       [0, 1]]...)