colour_checker_detection.extract_colour_checkers_segmentation¶
- colour_checker_detection.extract_colour_checkers_segmentation(image: ArrayLike, **kwargs: Any) Tuple[numpy.ndarray, ...] [source]¶
Extract the colour checkers sub-images in given image using segmentation.
- Parameters
image (ArrayLike) – Image to extract the colours checkers sub-images from.
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.
swatches – Colour checker swatches total count.
swatches_horizontal – Colour checker swatches horizontal columns count.
swatches_vertical – Colour checker swatches vertical row count.
swatches_count_minimum – Minimum swatches count to be considered for the detection.
swatches_count_maximum – Maximum swatches count to be considered for the detection.
swatches_chromatic_slice – A slice instance defining chromatic swatches used to detect if the colour checker is upside down.
swatches_achromatic_slice – A slice instance defining achromatic swatches used to detect if the colour checker is upside down.
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.
swatch_contour_scale – As the image is filtered, the swatches area will tend to shrink, the generated contours can thus be scaled.
cluster_contour_scale – 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 – Size the input image is resized to for detection.
fast_non_local_means_denoising_kwargs – Keyword arguments for
cv2.fastNlMeansDenoising()
definition.adaptive_threshold_kwargs – Keyword arguments for
cv2.adaptiveThreshold()
definition.interpolation_method – Interpolation method used when resizing the images, cv2.INTER_CUBIC and cv2.INTER_LINEAR methods are recommended.
kwargs (Any) –
- Returns
Tuple of colour checkers sub-images.
- Return type
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) >>> extract_colour_checkers_segmentation(image) ... (array([[[ 0.17908671, 0.14010708, 0.09243158], [ 0.17805016, 0.13058874, 0.09513047], [ 0.17175764, 0.13128328, 0.08811688], ..., [ 0.15934898, 0.13436384, 0.07479276], [ 0.17178158, 0.13138185, 0.07703256], [ 0.15082785, 0.11866678, 0.07680314]], [[ 0.16597673, 0.13563241, 0.08780421], [ 0.16490564, 0.13110894, 0.08601525], [ 0.16939694, 0.12963502, 0.08783565], ..., [ 0.14708202, 0.12856133, 0.0814603 ], [ 0.16883563, 0.12862256, 0.08452422], [ 0.16781917, 0.12363558, 0.07361614]], [[ 0.16326806, 0.13720085, 0.08925959], [ 0.16014062, 0.13585283, 0.08104862], [ 0.16657823, 0.12889633, 0.08870038], ..., [ 0.14619341, 0.13086307, 0.07367594], [ 0.16302426, 0.13062705, 0.07938427], [ 0.16618022, 0.1266259 , 0.07200021]], ..., [[ 0.1928642 , 0.14578913, 0.11224515], [ 0.18931177, 0.14416392, 0.10288388], [ 0.17707473, 0.1436448 , 0.09188452], ..., [ 0.16879168, 0.12867133, 0.09001681], [ 0.1699731 , 0.1287041 , 0.07616285], [ 0.17137891, 0.129711 , 0.07517841]], [[ 0.19514292, 0.1532704 , 0.10375113], [ 0.18217109, 0.14982903, 0.10452617], [ 0.18830594, 0.1469499 , 0.10896181], ..., [ 0.18234864, 0.12642328, 0.08047272], [ 0.17617388, 0.13000189, 0.06874527], [ 0.17108543, 0.13264084, 0.06309374]], [[ 0.16243187, 0.14983535, 0.08954653], [ 0.155507 , 0.14899652, 0.10273992], [ 0.17993385, 0.1498394 , 0.1099571 ], ..., [ 0.18079454, 0.1253967 , 0.07739887], [ 0.17239226, 0.13181566, 0.07806754], [ 0.17422497, 0.13277327, 0.07513551]]], dtype=float32),)