colour_checker_detection.detection.cluster_swatches#
- colour_checker_detection.detection.cluster_swatches(image: NDArrayFloat, swatches: NDArrayInt, swatch_contour_scale: float) NDArrayInt[source]#
Cluster swatches by expanding them and fitting rectangles to overlapping areas.
- Parameters:
image (NDArrayFloat) – Image containing the swatches. Only used for its shape.
swatches (NDArrayInt) – The swatches to cluster.
swatch_contour_scale (float) – The scale by which to expand the swatches.
- Returns:
The clusters of swatches.
- Return type:
NDArrayInt
Examples
>>> import numpy as np >>> image = np.zeros((600, 900, 3)) >>> swatches = np.array( ... [ ... [[100, 100], [200, 100], [200, 200], [100, 200]], ... [[300, 100], [400, 100], [400, 200], [300, 200]], ... ], ... dtype=np.int32, ... ) >>> cluster_swatches(image, swatches, 1.5) array([[[275, 75], [425, 75], [425, 225], [275, 225]], [[ 75, 75], [225, 75], [225, 225], [ 75, 225]]], dtype=int32)