colour_checker_detection.colour_checkers_coordinates_segmentation(image, additional_data=False)[source]

Detects the colour checkers coordinates in given image \(image\) using segmentation.

This is the core detection definition. The process is a follows:

  • Input image \(image\) is converted to a grayscale image \(image_g\).

  • Image \(image_g\) is denoised.

  • Image \(image_g\) is thresholded/segmented to image \(image_s\).

  • Image \(image_s\) is eroded and dilated to cleanup remaining noise.

  • Contours are detected on image \(image_s\).

  • Contours are filtered to only keep squares/swatches above and below defined surface area.

  • Squares/swatches are clustered to isolate region-of-interest that are potentially colour checkers: Contours are scaled by a third so that colour checkers swatches are expected to be joined, creating a large rectangular cluster. Rectangles are fitted to the clusters.

  • Clusters with an aspect ratio different to the expected one are rejected, a side-effect is that the complementary pane of the X-Rite ColorChecker Passport is omitted.

  • Clusters with a number of swatches close to SWATCHES are kept.

  • image (array_like) – Image to detect the colour checkers in.

  • additional_data (bool, optional) – Whether to output additional data.


List of colour checkers coordinates or ColourCheckersDetectionData class instance with additional data.

Return type

list or ColourCheckersDetectionData


  • Multiple colour checkers can be detected if presented in image.


>>> import os
>>> from colour import read_image
>>> from colour_checker_detection import TESTS_RESOURCES_DIRECTORY
>>> path = os.path.join(TESTS_RESOURCES_DIRECTORY,
...                     'colour_checker_detection', 'detection',
...                     'IMG_1967.png')
>>> image = read_image(path)
>>> colour_checkers_coordinates_segmentation(image)  
[array([[1065,  707],
       [ 369,  688],
       [ 382,  226],
       [1078,  246]]...)]