darsia.DiscreteColorRange#

class DiscreteColorRange(color_range, resolution=32)[source]#

Bases: ColorRange

A ColorRange discretised 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

colors

Get all colors in the discrete color range as an array.

shape

Get the shape of the discrete color raster.

min_color

Minimum color observed.

max_color

Maximum color observed.

color_mode

Whether the color range is relative to a baseline.

range

Tuple of color ranges observed.

center

Center of the color range.

extent

Color extent observed.

color_to_index(color)[source]#

Convert color array to the respective indices in the discrete color raster.

Parameters:
colornp.ndarray

Color array of shape (N,3).

flat_color_index(color)[source]#

Convert color array to the respective flat indices in the discrete color raster.

Parameters:
colornp.ndarray

Color array of shape (N,3).

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.