darsia.LabelColorPathMap#
- class LabelColorPathMap(color_paths=None)[source]#
-
Mapping between integer labels and their corresponding color paths.
Initialize the LabelColorPathMap.
- Parameters:
- color_paths
dict[int,darsia.ColorPath],optional Initial mapping of labels to color paths.
- 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 the color 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:
- path
Path The CSV file path to read.
- path
- Returns:
LabelColorPathMapwithreconstructedcolorpaths.
- 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_map
LabelColorPathMap The original color path map.
- num_segments
int The number of segments to use for refinement.
- distance_to_left
float,optional Value to extend the color path to the left (inter).
- distance_to_right
float,optional Value to extend the color path to the right.
- color_path_map
- Returns:
LabelColorPathMapThe refined color path map.