colour_checker_detection.detect_colour_checkers_inference#

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

Detect the colour checkers swatches in specified 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 (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.

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

  • extractor (Callable) – Callable responsible to extract the colour checker data from the inference results.

  • extractor_kwargs (dict | None) – Keyword arguments to pass to the extractor.

  • 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, apply_cctf_decoding=True)
...
(array([[  1.06845371e-01,   4.07868698e-02,   1.31441019e-02],
       [  3.50147694e-01,   1.29043385e-01,   4.78129089e-02],
       [  9.05092135e-02,   8.14050063e-02,   6.78419247e-02],
       [  7.56733939e-02,   6.07803836e-02,   1.10923871e-02],
       [  1.45852566e-01,   8.30223709e-02,   7.72851035e-02],
       [  1.00246392e-01,   1.61679372e-01,   6.92804456e-02],
       [  4.20029789e-01,   1.01915061e-01,   6.43535238e-03],
       [  6.03192598e-02,   5.23659140e-02,   8.95039141e-02],
       [  3.43519300e-01,   5.94778359e-02,   2.91121379e-02],
       [  7.70977959e-02,   2.71929316e-02,   3.07033304e-02],
       [  2.01079920e-01,   1.77687049e-01,   2.65044416e-03],
       [  3.80813688e-01,   1.33050218e-01,   1.23625272e-03],
       [  3.13875042e-02,   2.89476123e-02,   6.11585006e-02],
       [  6.44312650e-02,   1.22649640e-01,   1.42761841e-02],
       [  2.68237919e-01,   3.78787108e-02,   1.45872077e-02],
       [  4.78466213e-01,   2.28658482e-01,   4.09228291e-04],
       [  2.93730289e-01,   5.41352853e-02,   5.86953908e-02],
       [  2.68954877e-02,   8.18221569e-02,   7.10325763e-02],
       [  5.08168578e-01,   3.31246942e-01,   1.61783472e-01],
       [  3.54471445e-01,   2.30975851e-01,   1.14853390e-01],
       [  2.28191391e-01,   1.48212209e-01,   7.24881589e-02],
       [  1.13720678e-01,   7.50572383e-02,   3.62149812e-02],
       [  5.70064113e-02,   3.80622372e-02,   1.82537530e-02],
       [  2.30789520e-02,   1.61857158e-02,   7.48640532e-03]...),)