darsia.DiscreteColorRange#
- class DiscreteColorRange(color_range, resolution=32)[source]#
Bases:
ColorRangeA
ColorRangediscretised into a fixed number of bins.Methods
color_to_index(color)Convert color array to the respective indices in the discrete color raster.
flat_color_index(color)Convert color array to the respective flat indices in the discrete color raster.
flatten_index(index)Convert a color to the respective flat index in the discrete color raster.
from_images(images[, baseline, mask])Create a ColorRange from a list of images.
load(path)Load color range from a json file.
load_from_dict(data)Load color range from a dictionary.
save(path)Save color range to a json file.
to_dict()Convert color range to a dictionary.
Attributes
Get all colors in the discrete color range as an array.
Get the shape of the discrete color raster.
min_colorMinimum color observed.
max_colorMaximum color observed.
color_modeWhether the color range is relative to a baseline.
rangeTuple of color ranges observed.
centerCenter of the color range.
extentColor extent observed.
- color_to_index(color)[source]#
Convert color array to the respective indices in the discrete color raster.
- Parameters:
- color
np.ndarray Color array of shape (N,3).
- color
- flat_color_index(color)[source]#
Convert color array to the respective flat indices in the discrete color raster.
- Parameters:
- color
np.ndarray Color array of shape (N,3).
- color
- flatten_index(index)[source]#
Convert a color to the respective flat index in the discrete color raster.
- property colors#
Get all colors in the discrete color range as an array.
- property shape#
Get the shape of the discrete color raster.