colour_checker_detection.detect_colour_checkers_segmentation#
- colour_checker_detection.detect_colour_checkers_segmentation(image: ArrayLike, samples: int = 16, additional_data: bool = False, **kwargs: Any) Tuple[DataDetectColourCheckersSegmentation, ...] | Tuple[NDArrayFloat, ...] [source]#
Detect the colour checkers swatches in given image using segmentation.
- Parameters
image (array_like) – Image to detect the colour checkers swatches in.
samples (int) – Samples count to use to compute the swatches colours. The effective samples count is \(samples^2\).
additional_data (bool, optional) – Whether to output additional data.
aspect_ratio – Colour checker aspect ratio, e.g. 1.5.
aspect_ratio_minimum – Minimum colour checker aspect ratio for detection: projective geometry might reduce the colour checker aspect ratio.
aspect_ratio_maximum – Maximum colour checker aspect ratio for detection: projective geometry might increase the colour checker aspect ratio.
swatches – Colour checker swatches total count.
swatches_horizontal – Colour checker swatches horizontal columns count.
swatches_vertical – Colour checker swatches vertical row count.
swatches_count_minimum – Minimum swatches count to be considered for the detection.
swatches_count_maximum – Maximum swatches count to be considered for the detection.
swatches_chromatic_slice – A slice instance defining chromatic swatches used to detect if the colour checker is upside down.
swatches_achromatic_slice – A slice instance defining achromatic swatches used to detect if the colour checker is upside down.
swatch_minimum_area_factor – Swatch minimum area factor \(f\) with the minimum area \(m_a\) expressed as follows: \(m_a = image_w * image_h / s_c / f\) where \(image_w\), \(image_h\) and \(s_c\) are respectively the image width, height and the swatches count.
swatch_contour_scale – As the image is filtered, the swatches area will tend to shrink, the generated contours can thus be scaled.
cluster_contour_scale – As the swatches are clustered, it might be necessary to adjust the cluster scale so that the masks are centred better on the swatches.
working_width – Size the input image is resized to for detection.
fast_non_local_means_denoising_kwargs – Keyword arguments for
cv2.fastNlMeansDenoising()
definition.adaptive_threshold_kwargs – Keyword arguments for
cv2.adaptiveThreshold()
definition.interpolation_method – Interpolation method used when resizing the images, cv2.INTER_CUBIC and cv2.INTER_LINEAR methods are recommended.
kwargs (Any) –
- Returns
Tuple of
DataDetectColourCheckersSegmentation
class instances or colour checkers swatches.- Return type
class`tuple`
Examples
>>> import os >>> from colour import read_image >>> from colour_checker_detection import ROOT_RESOURCES_TESTS >>> path = os.path.join( ... ROOT_RESOURCES_TESTS, ... "colour_checker_detection", ... "detection", ... "IMG_1967.png", ... ) >>> image = read_image(path) >>> detect_colour_checkers_segmentation(image) (array([[ 0.361626... , 0.2241066..., 0.1187837...], [ 0.6280594..., 0.3950883..., 0.2434766...], [ 0.3326232..., 0.3156182..., 0.2891038...], [ 0.3048414..., 0.2738973..., 0.1069985...], [ 0.4174869..., 0.3199669..., 0.3081552...], [ 0.347873 ..., 0.4413193..., 0.2931614...], [ 0.6816301..., 0.3539050..., 0.0753397...], [ 0.2731050..., 0.2528467..., 0.3312920...], [ 0.6192335..., 0.2703833..., 0.1866387...], [ 0.3068567..., 0.1803366..., 0.1919807...], [ 0.4866354..., 0.4594004..., 0.0374186...], [ 0.6518523..., 0.4010608..., 0.0171886...], [ 0.1941571..., 0.1855801..., 0.2750632...], [ 0.2799946..., 0.3854609..., 0.1241038...], [ 0.5537481..., 0.2139004..., 0.1267332...], [ 0.7208045..., 0.5152904..., 0.0061946...], [ 0.5778360..., 0.2578533..., 0.2687992...], [ 0.1809450..., 0.3174742..., 0.2959902...], [ 0.7427522..., 0.6107554..., 0.4398439...], [ 0.6296108..., 0.5177606..., 0.3728032...], [ 0.5139589..., 0.4216307..., 0.2992694...], [ 0.3704401..., 0.3033927..., 0.2093089...], [ 0.2641854..., 0.2154007..., 0.1441267...], [ 0.1650098..., 0.1345239..., 0.0817437...]], dtype=float32),)