colour_checker_detection.extractor_inference#

colour_checker_detection.extractor_inference(image: ArrayLike, inference_data: Any, samples: int = 32, cctf_decoding: Callable = eotf_sRGB, apply_cctf_decoding: bool = False, inferred_confidence: float = 0.85, working_width: int = 1440, additional_data: bool = False, **kwargs: Any) tuple[DataDetectionColourChecker, ...] | tuple[NDArrayFloat, ...][source]#

Extract colour swatches using inference-based methods.

This function takes inference data (bounding boxes/contours) and extracts colors using ML-guided sampling approach.

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

  • inference_data (Any) – Inference data containing detected contours and confidence scores.

  • 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.

  • inferred_confidence (float) – Minimum confidence threshold for inference results.

  • working_width (int) – Working width for image processing.

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

  • 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,
...     inferencer_default,
...     extractor_inference,
... )
>>> path = os.path.join(
...     ROOT_RESOURCES_TESTS,
...     "colour_checker_detection",
...     "detection",
...     "IMG_1967.png",
... )
>>> image = read_image(path)
>>> inference_data = inferencer_default(image)
>>> extractor_inference(image, inference_data)
(array([[ 0.36007342,  0.22303678,  0.1176604 ],
       [ 0.62607545,  0.39443627,  0.24180005],
       [ 0.33200133,  0.3159002 ,  0.28866205],
       [ 0.304158  ,  0.27339226,  0.10521446],
       [ 0.41758743,  0.31893715,  0.3078802 ],
       [ 0.34878933,  0.43871346,  0.29159448],
       [ 0.67982006,  0.3523331 ,  0.070414  ],
       [ 0.27139527,  0.25354654,  0.33075848],
       [ 0.6207255 ,  0.27040577,  0.18629737],
       [ 0.3071541 ,  0.17973351,  0.19184262],
       [ 0.48536164,  0.45853454,  0.03277667],
       [ 0.65034246,  0.4002059 ,  0.01576474],
       [ 0.19285583,  0.18593574,  0.27413625],
       [ 0.28041738,  0.38502172,  0.12292562],
       [ 0.5545266 ,  0.21458797,  0.12545331],
       [ 0.7207607 ,  0.515445  ,  0.005255  ],
       [ 0.5779864 ,  0.25786015,  0.2685206 ],
       [ 0.17531879,  0.3166867 ,  0.29529998],
       [ 0.7404447 ,  0.61071527,  0.4387243 ],
       [ 0.6295517 ,  0.5178505 ,  0.37301064],
       [ 0.51465   ,  0.42113122,  0.29825154],
       [ 0.37083188,  0.30355468,  0.20928001],
       [ 0.26390594,  0.21514489,  0.1433286 ],
       [ 0.16213489,  0.13396774,  0.08086098]], dtype=float32),)