colour_checker_detection.detect_colour_checkers_inference#

colour_checker_detection.detect_colour_checkers_inference(image: str | ArrayLike, samples: int = 32, cctf_decoding=eotf_sRGB, apply_cctf_decoding: bool = False, inferencer: Callable = inferencer_default, inferencer_kwargs: dict | None = None, show: bool = False, additional_data: bool = False, **kwargs: Any) Tuple[DataDetectionColourChecker | NDArrayFloat, ...][source]#

Detect the colour checkers swatches in given image using inference.

Parameters:
  • image (str | ArrayLike) – Image (or image path to read the image from) to detect the colour checker rectangles from.

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

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

  • inferencer (Callable) – Callable responsible to make predictions on the image and extract the colour checker rectangles.

  • inferencer_kwargs (dict | None) – Keyword arguments to pass to the inferencer.

  • show (bool) – Whether to show various debug images.

  • additional_data (bool) – 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.

  • 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 DataDetectionColourChecker 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_inference(image)  
(array([[ 0.3602327 ,  0.22158547,  0.11813926],
       [ 0.62800723,  0.39357048,  0.24196433],
       [ 0.3284166 ,  0.31669423,  0.28818974],
       [ 0.3072932 ,  0.2744136 ,  0.10451803],
       [ 0.4204691 ,  0.31953654,  0.30901137],
       [ 0.34471545,  0.44057423,  0.29297924],
       [ 0.678418  ,  0.35242617,  0.06670552],
       [ 0.27259055,  0.2535471 ,  0.32912973],
       [ 0.6190633 ,  0.27043283,  0.18543543],
       [ 0.30721852,  0.18180828,  0.19161244],
       [ 0.4858081 ,  0.46007228,  0.03085822],
       [ 0.6499356 ,  0.4018961 ,  0.01579806],
       [ 0.19425018,  0.18621376,  0.27193058],
       [ 0.27500305,  0.38600868,  0.1245231 ],
       [ 0.55459476,  0.21477987,  0.12434786],
       [ 0.71898675,  0.5149239 ,  0.00561224],
       [ 0.5787967 ,  0.25837064,  0.2693373 ],
       [ 0.1743919 ,  0.31709513,  0.29550385],
       [ 0.7383609 ,  0.60645705,  0.43850273],
       [ 0.62609893,  0.5172464 ,  0.36816722],
       [ 0.5117422 ,  0.4191487 ,  0.3013721 ],
       [ 0.36412936,  0.2987345 ,  0.20754097],
       [ 0.26675388,  0.21421173,  0.14176223],
       [ 0.15856811,  0.13483825,  0.07938566]], dtype=float32),)