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, extractor: Callable = extractor_segmentation, extractor_kwargs: dict | None = None, show: bool = False, additional_data: Literal[True] = True, **kwargs: Any) Tuple[DataDetectionColourChecker, ...][source]#
- 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, extractor: Callable = extractor_segmentation, extractor_kwargs: dict | None = None, show: bool = False, *, additional_data: Literal[False], **kwargs: Any) Tuple[NDArrayFloat, ...]
- colour_checker_detection.detect_colour_checkers_segmentation(image: str | ArrayLike, samples: int, cctf_decoding: Callable, apply_cctf_decoding: bool, segmenter: Callable, segmenter_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 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.extractor (Callable) – Callable responsible to extract the colour checker data from the segmented rectangles.
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.
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
DataDetectionColourCheckerclass 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, apply_cctf_decoding=True) ... (array([[ 1.06804565e-01, 4.08109687e-02, 1.31266015e-02], [ 3.49683374e-01, 1.29072860e-01, 4.77699488e-02], [ 9.05181840e-02, 8.14911500e-02, 6.78349435e-02], [ 7.58600757e-02, 6.07827008e-02, 1.10303042e-02], [ 1.45751402e-01, 8.31151009e-02, 7.72669688e-02], [ 1.00159235e-01, 1.62195116e-01, 6.91367984e-02], [ 4.20038819e-01, 1.01927504e-01, 6.38073916e-03], [ 6.02441281e-02, 5.23594357e-02, 8.94734785e-02], [ 3.43939215e-01, 5.94407171e-02, 2.92109884e-02], [ 7.70443529e-02, 2.71991435e-02, 3.07092462e-02], [ 2.01171950e-01, 1.77795976e-01, 2.66185054e-03], [ 3.81304830e-01, 1.33062363e-01, 1.23752898e-03], [ 3.14101577e-02, 2.89250631e-02, 6.13652393e-02], [ 6.45340234e-02, 1.22705154e-01, 1.41930664e-02], [ 2.68294245e-01, 3.78271416e-02, 1.45846475e-02], [ 4.78512675e-01, 2.28180945e-01, 4.21307486e-04], [ 2.93216556e-01, 5.40601388e-02, 5.87599911e-02], [ 2.61003822e-02, 8.16240311e-02, 7.08173811e-02], [ 5.06426811e-01, 3.29764754e-01, 1.61412135e-01], [ 3.52356732e-01, 2.30743274e-01, 1.14147641e-01], [ 2.27152765e-01, 1.47627085e-01, 7.27180764e-02], [ 1.12553783e-01, 7.42645189e-02, 3.58113647e-02], [ 5.65953329e-02, 3.79680507e-02, 1.81693807e-02], [ 2.30163466e-02, 1.61432363e-02, 7.43864896e-03]]...),)