darsia.LabelColorPathMapRegression#
- class LabelColorPathMapRegression(labels, color_range, resolution=11, mask=None, ignore_labels=[])[source]#
Bases:
objectAlgorithmic definition of relative color paths through regression for labeled images.
Methods
base_color_image(image)Create an image where each label is colored by its base color.
expand_color_spectrum(color_spectrum[, ...])Expand the color spectrum through linear regression.
find_color_path(color_spectrum[, ignore, ...])Find relative color paths for each label in the spectrum map.
get_base_colors(image[, verbose])Get the base colors for each label in the image.
get_color_spectrum(images[, baseline, ...])Get the color spectrum for each label in the image.
get_mean_base_color(image)Get the mean base color across all labels in the image.
Attributes
Labeled image to define color paths for.
Color range for the regression.
Discrete color range for regression.
Mask to apply when analyzing colors.
Labels to ignore during color path regression.
Color mode.
- base_color_image(image)[source]#
Create an image where each label is colored by its base color.
- Parameters:
- image
darsia.Image The image from which to extract base colors.
- image
- Returns:
darsia.ImageAn image where each label is colored by its base color.
- expand_color_spectrum(color_spectrum, min_points=6, verbose=False)[source]#
Expand the color spectrum through linear regression.
- Parameters:
- color_spectrum
ColorSpectrumorLabelColorSpectrumMap The color spectrum to expand.
- min_points
int Minimum number of significant points to perform regression.
- verbosebool
Whether to print additional information.
- color_spectrum
- Returns:
LabelColorSpectrumMapThe expanded color spectrum.
- find_color_path(color_spectrum, ignore=None, num_segments=1, directory=None, weighting='threshold', mode='auto', preview_image=None, preview_images=None, preview_baseline=None, ignore_labels=None, verbose=False)[source]#
Find relative color paths for each label in the spectrum map.
- Parameters:
- color_spectrum
LabelColorSpectrumMap The color spectrum map to analyze.
- ignore
LabelColorSpectrumMap|None The color spectrum map to ignore.
- num_segments
int The number of segments for the color path.
- weighting
Literal How to use histogram counts when fitting each path.
"threshold"(default) uses binary 0/1 weights from the spectrum threshold – counts are not used beyond that."wls","wls_sqrt", and"wls_log"use count-weighted average errors – see_find_color_path()for details.- mode
Literal Color-path selection mode.
"auto"returns the automated result."manual"enables interactive key-color postprocessing.- preview_image
darsia.Image|None Calibration image for manual preview.
- preview_images
list[darsia.Image] |None Calibration images for manual preview navigation.
- preview_baseline
darsia.Image|None Baseline used for relative color preview.
- ignore_labels
list[int] |None Label IDs to skip fitting and produce zero-paths for instead. Defaults to None (no labels ignored).
- verbosebool
Whether to print additional information.
- color_spectrum
- Returns:
LabelColorPathMapThe relative color path map through the significant boxes.
- get_base_colors(image, verbose=False)[source]#
Get the base colors for each label in the image.
- Parameters:
- image
darsia.Image The image from which to extract base colors.
- verbosebool
Whether to print additional information.
- image
- Returns:
LabelColorMapAn object containing the base colors for each label.
- get_color_spectrum(images, baseline=None, ignore=None, threshold_zero=0.0, threshold_significant=0.0, path=None, verbose=False)[source]#
Get the color spectrum for each label in the image.
The color spectrum is calculated by analyzing the distribution of colors within each label across the provided images. This involves creating a 3D histogram of color occurrences, which is then normalized to identify significant colors.
- Parameters:
- images
list[darsia.Image] The images to analyze.
- baseline
darsia.Image|None The baseline image for comparison.
- ignore
darsia.LabelColorSpectrumMap|darsia.ColorSpectrum|None Colors to ignore in the spectrum.
- threshold_zero
float The threshold for zeroing out insignificant colors.
- threshold_significant
float The threshold for significant colors.
- path
Path Folder to store images.
- verbosebool
Whether to print verbose output.
- images
- Returns:
LabelColorSpectrumMapThe color spectrum for each label.
- get_mean_base_color(image)[source]#
Get the mean base color across all labels in the image.
- Parameters:
- image
darsia.Image The image from which to extract base colors.
- image
- Returns:
np.ndarrayThe mean base color across all labels.
- color_mode#
Color mode.
- color_range#
Color range for the regression.
- discrete_color_range#
Discrete color range for regression.
- ignore_labels#
Labels to ignore during color path regression.
- labels#
Labeled image to define color paths for.
- mask#
Mask to apply when analyzing colors.