colour_checker_detection.extractor_segmentation#

colour_checker_detection.extractor_segmentation(image: ArrayLike, segmentation_data: Any, samples: int = 32, cctf_decoding: Callable = eotf_sRGB, apply_cctf_decoding: bool = False, additional_data: Literal[True] = True, **kwargs: Any) tuple[DataDetectionColourChecker, ...][source]#
colour_checker_detection.extractor_segmentation(image: ArrayLike, segmentation_data: Any, samples: int = 32, cctf_decoding: Callable = eotf_sRGB, apply_cctf_decoding: bool = False, *, additional_data: Literal[False], **kwargs: Any) tuple[NDArrayFloat, ...]
colour_checker_detection.extractor_segmentation(image: ArrayLike, segmentation_data: Any, samples: int, cctf_decoding: Callable, apply_cctf_decoding: bool, additional_data: Literal[False], **kwargs: Any) tuple[NDArrayFloat, ...]

Extract colour swatches using segmentation-based methods.

This function takes segmentation data (rectangles/quadrilaterals) and extracts colors using the standard geometric sampling approach.

Parameters:
  • image (ArrayLike) – Image to extract colours from.

  • segmentation_data (Any) – Segmentation data containing detected rectangles and swatches.

  • samples (int) – Sample count to use to average (mean) the swatches colours. The effective sample count is \(samples^2\).

  • cctf_decoding (Callable) – Decoding colour component transfer function / opto-electronic transfer function used when converting the image from 8-bit to float.

  • apply_cctf_decoding (bool) – Apply the decoding colour component transfer function / opto-electronic transfer function.

  • additional_data (bool) – Whether to include additional extraction data.

  • interpolation_method – Interpolation method used when resizing the images, cv2.INTER_CUBIC and cv2.INTER_LINEAR methods are recommended.

  • working_width – Width the input image is resized to for detection.

  • aspect_ratio – Colour checker aspect ratio, e.g. 1.5.

  • kwargs (Any)

Returns:

Tuple of detected colour checker data objects.

Return type:

tuple

Examples

>>> import os
>>> from colour import read_image
>>> from colour_checker_detection import (
...     ROOT_RESOURCES_TESTS,
...     segmenter_default,
...     extractor_segmentation,
... )
>>> path = os.path.join(
...     ROOT_RESOURCES_TESTS,
...     "colour_checker_detection",
...     "detection",
...     "IMG_1967.png",
... )
>>> image = read_image(path)
>>> segmentation_data = segmenter_default(image, additional_data=True)
>>> extractor_segmentation(image, segmentation_data)
...
(array([[ 0.36018878,  0.22291452,  0.11730091],
       [ 0.6256498 ,  0.39444408,  0.241824  ],
       [ 0.33206907,  0.31609666,  0.2886104 ],
       [ 0.30452022,  0.27339727,  0.10480344],
       [ 0.41740698,  0.3191239 ,  0.30785984],
       [ 0.3486532 ,  0.43936515,  0.29126465],
       [ 0.6797462 ,  0.3522702 ,  0.06983876],
       [ 0.27157846,  0.25354025,  0.33056694],
       [ 0.62124234,  0.27033532,  0.18669768],
       [ 0.3070325 ,  0.17978221,  0.19183952],
       [ 0.48548093,  0.45865163,  0.03294417],
       [ 0.6508147 ,  0.4002312 ,  0.01611003],
       [ 0.1930163 ,  0.18572474,  0.2745065 ],
       [ 0.28079677,  0.38511798,  0.12274227],
       [ 0.5547266 ,  0.21451429,  0.12551409],
       [ 0.7207452 ,  0.5150524 ,  0.00542995],
       [ 0.5774373 ,  0.25776303,  0.26855013],
       [ 0.17295608,  0.31638905,  0.2951069 ],
       [ 0.7390023 ,  0.60931826,  0.43826106],
       [ 0.62775826,  0.5176888 ,  0.3718117 ],
       [ 0.51389074,  0.42036685,  0.29863322],
       [ 0.3694671 ,  0.30227602,  0.20832038],
       [ 0.2630599 ,  0.21490613,  0.14286397],
       [ 0.16101658,  0.13380753,  0.08050805]]...),)