darsia.ColorRange#

class ColorRange(min_color, max_color, color_mode=ColorMode.ABSOLUTE)[source]#

Bases: object

Class to track the range of colors in an image or a set of images.

Initialize ColorRange from min and max color values.

Parameters:
min_colornp.ndarray

Minimum color values (RGB).

max_colornp.ndarray

Maximum color values (RGB).

Methods

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

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.

classmethod from_images(images, baseline=None, mask=None, **kwargs)[source]#

Create a ColorRange from a list of images.

Parameters:
imageslist[darsia.Image]

List of images to analyze.

baselinedarsia.Image, optional

Baseline image for relative color range.

maskdarsia.Image, optional

Mask image to restrict analysis area.

classmethod load(path)[source]#

Load color range from a json file.

Parameters:
pathPath

Path to the json file.

Returns:
ColorRange

Loaded color range.

classmethod load_from_dict(data)[source]#

Load color range from a dictionary.

Parameters:
datadict

Dictionary representation of the color range.

Returns:
ColorRange

Loaded color range.

save(path)[source]#

Save color range to a json file.

Parameters:
pathPath

Path to the json file.

to_dict()[source]#

Convert color range to a dictionary.

Returns:
dict

Dictionary representation of the color range.

center#

Center of the color range.

color_mode#

Whether the color range is relative to a baseline.

extent#

Color extent observed.

max_color#

Maximum color observed.

min_color#

Minimum color observed.

range#

Tuple of color ranges observed.