colour_checker_detection.detection.sample_colour_checker#

colour_checker_detection.detection.sample_colour_checker(image: ArrayLike, quadrilateral, rectangle, samples=32, **kwargs) DataDetectionColourChecker[source]#

Sample the colour checker using the given source quadrilateral, i.e. detected colour checker in the image, and the given target rectangle.

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

  • quadrilateral – Source quadrilateral where the colour checker has been detected.

  • rectangle – Target rectangle to warp the detected source quadrilateral onto.

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

  • reference_values – Reference values for the colour checker of interest.

  • swatches_horizontal – Colour checker swatches horizontal columns count.

  • swatches_vertical – Colour checker swatches vertical row count.

  • transform – Transform to apply to the colour checker image post-detection.

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

  • working_height – Height the input image is resized to for detection.

Returns:

Sampling process data.

Return type:

colour_checker.DataDetectionColourChecker

References

[Dal24]

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)
>>> quadrilateral = np.array([[358, 691], [373, 219], [1086, 242], [1071, 713]])
>>> rectangle = np.array([[1440, 0], [1440, 960], [0, 960], [0, 0]])
>>> colour_checkers_data = sample_colour_checker(image, quadrilateral, rectangle)
>>> colour_checkers_data.swatch_colours  
array([[ 0.75710917,  0.6763046 ,  0.47606474],
       [ 0.25871587,  0.21974973,  0.16204563],
       [ 0.15012611,  0.11881837,  0.07829906],
       [ 0.14475887,  0.11828972,  0.0747117 ],
       [ 0.15182742,  0.12059662,  0.07984065],
       [ 0.15811475,  0.12584405,  0.07951307],
       [ 0.9996331 ,  0.827563  ,  0.5362377 ],
       [ 0.2615244 ,  0.22938406,  0.16862768],
       [ 0.1580963 ,  0.11951645,  0.0775518 ],
       [ 0.16762769,  0.13303326,  0.08851139],
       [ 0.17338796,  0.14148802,  0.08979498],
       [ 0.17304046,  0.1419515 ,  0.09080467],
       [ 1.        ,  0.9890205 ,  0.6780832 ],
       [ 0.25435534,  0.2206379 ,  0.1569271 ],
       [ 0.15027192,  0.12475526,  0.0784394 ],
       [ 0.3458355 ,  0.21429974,  0.1121798 ],
       [ 0.36254194,  0.2259509 ,  0.11665937],
       [ 0.62459683,  0.39099   ,  0.24112946],
       [ 0.97804743,  1.        ,  0.86419195],
       [ 0.25577253,  0.22349517,  0.1584489 ],
       [ 0.1595923 ,  0.12591116,  0.08147947],
       [ 0.35486832,  0.21910854,  0.11063413],
       [ 0.3630804 ,  0.22740598,  0.12138989],
       [ 0.62340593,  0.39334935,  0.24371558]]...)
>>> colour_checkers_data.swatch_masks.shape
(24, 4)
>>> colour_checkers_data.colour_checker.shape
(960, 1440, 3)