colour_checker_detection.detect_colour_checkers_segmentation

colour_checker_detection.detect_colour_checkers_segmentation(image, samples=16, additional_data=False, **kwargs)[source]

Detects the colour checkers swatches in given image using segmentation.

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

  • samples (int) – Samples count to use to compute the swatches colours. The effective samples count is \(samples^2\).

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

  • aspect_ratio (numeric, optional) – Colour checker aspect ratio, e.g. 1.5.

  • aspect_ratio_minimum (numeric, optional) – Minimum colour checker aspect ratio for detection: projective geometry might reduce the colour checker aspect ratio.

  • aspect_ratio_maximum (numeric, optional) – Maximum colour checker aspect ratio for detection: projective geometry might increase the colour checker aspect ratio.

  • swatches (int, optional) – Colour checker swatches total count.

  • swatches_horizontal (int, optional) – Colour checker swatches horizontal columns count.

  • swatches_vertical (int, optional) – Colour checker swatches vertical row count.

  • swatches_count_minimum (numeric, optional) – Minimum swatches count to be considered for the detection.

  • swatches_count_maximum (numeric, optional) – Maximum swatches count to be considered for the detection.

  • swatches_chromatic_slice (numeric, optional) – A slice instance defining chromatic swatches used to detect if the colour checker is upside down.

  • swatches_achromatic_slice (numeric, optional) – A slice instance defining achromatic swatches used to detect if the colour checker is upside down.

  • swatch_minimum_area_factor (numeric, optional) – 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 (numeric, optional) – As the image is filtered, the swatches area will tend to shrink, the generated contours can thus be scaled.

  • cluster_contour_scale (numeric, optional) – As the swatches are clustered, it might be necessary to adjust the cluster scale so that the masks are centred better on the swatches.

  • working_width (int, optional) – Size the input image is resized to for detection.

  • fast_non_local_means_denoising_kwargs (dict, optional) – Keyword arguments for cv2.fastNlMeansDenoising() definition.

  • adaptive_threshold_kwargs (dict, optional) – Keyword arguments for cv2.adaptiveThreshold() definition.

  • interpolation_method (int, optional) – {cv2.INTER_CUBIC, cv2.INTER_NEAREST, cv2.INTER_LINEAR, cv2.INTER_AREA, cv2.INTER_LANCZOS4, cv2.INTER_LINEAR_EXACT, cv2.INTER_NEAREST_EXACT, cv2.INTER_MAX, cv2.WARP_FILL_OUTLIERS, cv2.WARP_INVERSE_MAP}, Interpolation method used when resizing the images, cv2.INTER_CUBIC and cv2.INTER_LINEAR methods are recommended.

Returns

List of colour checkers swatches or ColourCheckerSwatchesData class instances.

Return type

list

Examples

>>> 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)
>>> detect_colour_checkers_segmentation(image)  
[array([[ 0.3616269...,  0.2241066...,  0.1187838...],
       [ 0.6280594...,  0.3950882...,  0.2434766...],
       [ 0.3326231...,  0.3156182...,  0.2891038...],
       [ 0.3048413...,  0.2738974...,  0.1069985...],
       [ 0.4174869...,  0.3199669...,  0.3081552...],
       [ 0.3478729...,  0.4413193...,  0.2931614...],
       [ 0.6816301...,  0.3539050...,  0.0753397...],
       [ 0.2731048...,  0.2528467...,  0.331292 ...],
       [ 0.6192336...,  0.2703833...,  0.1866386...],
       [ 0.3068567...,  0.1803366...,  0.1919807...],
       [ 0.4866353...,  0.4594004...,  0.0374185...],
       [ 0.6518524...,  0.4010608...,  0.0171887...],
       [ 0.1941569...,  0.1855801...,  0.2750632...],
       [ 0.2799947...,  0.385461 ...,  0.1241038...],
       [ 0.5537481...,  0.2139004...,  0.1267332...],
       [ 0.7208043...,  0.5152904...,  0.0061947...],
       [ 0.577836 ...,  0.2578533...,  0.2687992...],
       [ 0.1809449...,  0.3174741...,  0.2959902...],
       [ 0.7427522...,  0.6107554...,  0.439844 ...],
       [ 0.6296108...,  0.5177607...,  0.3728032...],
       [ 0.5139589...,  0.4216308...,  0.2992694...],
       [ 0.3704402...,  0.3033927...,  0.2093090...],
       [ 0.2641854...,  0.2154006...,  0.1441268...],
       [ 0.1650097...,  0.1345238...,  0.0817438...]], dtype=float32)]