colour_checker_detection.detect_colour_checkers_segmentation#
- colour_checker_detection.detect_colour_checkers_segmentation(image: str | ArrayLike, samples: int = 32, cctf_decoding: Callable = eotf_sRGB, apply_cctf_decoding: bool = False, segmenter: Callable = segmenter_default, segmenter_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 segmentation.
- Parameters:
image (str | ArrayLike) – Image (or image path to read the image from) to detect the colour checkers swatches 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.
segmenter (Callable) – Callable responsible to segment the image and extract the colour checker rectangles.
segmenter_kwargs (dict | None) – Keyword arguments to pass to the
segmenter
.show (bool) – Whether to show various debug images.
additional_data (bool) – Whether to output additional data.
adaptive_threshold_kwargs – Keyword arguments for
cv2.adaptiveThreshold()
definition.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.
bilateral_filter_iterations – Number of iterations to use for bilateral filtering.
bilateral_filter_kwargs – Keyword arguments for
cv2.bilateralFilter()
definition.convolution_iterations – Number of iterations to use for the erosion / dilation process.
convolution_kernel – Convolution kernel to use for the erosion / dilation process.
interpolation_method – Interpolation method used when resizing the images, cv2.INTER_CUBIC and cv2.INTER_LINEAR methods are recommended.
reference_values – Reference values for the colour checker of interest.
swatch_contour_scale – As the image is filtered, the swatches area will tend to shrink, the generated contours can thus be scaled.
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.
swatches – Colour checker swatches total count.
swatches_achromatic_slice – A slice instance defining achromatic swatches used to detect if the colour checker is upside down.
swatches_chromatic_slice – A slice instance defining chromatic swatches used to detect if the colour checker is upside down.
swatches_count_maximum – Maximum swatches count to be considered for the detection.
swatches_count_minimum – Minimum swatches count to be considered for the detection.
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.
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_segmentation(image) (array([[ 0.360005 , 0.22310828, 0.11760835], [ 0.6258309 , 0.39448667, 0.24166533], [ 0.33198 , 0.31600377, 0.28866866], [ 0.3046006 , 0.273321 , 0.10486555], [ 0.41751358, 0.31914026, 0.30789137], [ 0.34866226, 0.43934596, 0.29126382], [ 0.67983997, 0.35236534, 0.06997226], [ 0.27118555, 0.25352538, 0.33078724], [ 0.62091863, 0.27034152, 0.18652563], [ 0.3071613 , 0.17978874, 0.19181632], [ 0.48547146, 0.4585586 , 0.03294956], [ 0.6507678 , 0.40023172, 0.01607676], [ 0.19286253, 0.18585181, 0.27459183], [ 0.28054565, 0.38513032, 0.1224441 ], [ 0.5545431 , 0.21436104, 0.12549178], [ 0.72068894, 0.51493925, 0.00548734], [ 0.5772921 , 0.2577179 , 0.2685553 ], [ 0.17289193, 0.3163792 , 0.2950853 ], [ 0.7394083 , 0.60953134, 0.4383072 ], [ 0.6281671 , 0.51759964, 0.37215686], [ 0.51360977, 0.42048824, 0.2985709 ], [ 0.36953217, 0.30218402, 0.20827036], [ 0.26286703, 0.21493268, 0.14277342], [ 0.16102524, 0.13381621, 0.08047409]]...),)