darsia.LabelColorPathMap#

class LabelColorPathMap(color_paths=None)[source]#

Bases: dict[int, ColorPath]

Mapping between integer labels and their corresponding color paths.

Initialize the LabelColorPathMap.

Parameters:
color_pathsdict[int, darsia.ColorPath], optional

Initial mapping of labels to color paths.

Methods

clear()

copy()

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

load_csv(path)

Load color paths from a CSV file.

pop(key[, default])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

refine(color_path_map, num_segments[, ...])

Refine each color path in the map by increasing the number of segments.

save_csv(path)

Save color paths to a CSV file.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

show_cmaps()

Show the color paths.

show_paths()

Show the color paths.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

classmethod load_csv(path)[source]#

Load color paths from a CSV file.

Expects columns: label, segment_index, r, g, b, rel_r, rel_g, rel_b, base_r, base_g, base_b.

Parameters:
pathPath

The CSV file path to read.

Returns:
LabelColorPathMap with reconstructed color paths.
classmethod refine(color_path_map, num_segments, distance_to_left=None, distance_to_right=None, mode='relative')[source]#

Refine each color path in the map by increasing the number of segments.

Parameters:
color_path_mapLabelColorPathMap

The original color path map.

num_segmentsint

The number of segments to use for refinement.

distance_to_leftfloat, optional

Value to extend the color path to the left (inter).

distance_to_rightfloat, optional

Value to extend the color path to the right.

Returns:
LabelColorPathMap

The refined color path map.

save_csv(path)[source]#

Save color paths to a CSV file.

One row per (label, segment_index) with columns: label, segment_index, r, g, b, rel_r, rel_g, rel_b, base_r, base_g, base_b

Parameters:
pathPath

The CSV file path to write.

show_cmaps()[source]#

Show the color paths.

show_paths()[source]#

Show the color paths.