Core.Colors package

Submodules

Core.Colors.color_interpolator module

Core.Colors.color_interpolator.interpolate_lab(rgb1, rgb2, v, v0, v1)[source]

Core.Colors.colortree module

class Core.Colors.colortree.ColorTree(depth=4, cmap='viridis', color_u=array([0.7254902, 0.79607843, 0.78823529]), v_min=0, v_max=1, u_min=0, u_max=1, invert_u=False)[source]

Bases: object

A colormap class for visualizing data with uncertainty using a tree-based approach, inspired by VSUP (Value-Suppressing Uncertainty Palettes). It generates colors based on value and uncertainty levels using a colormap and uncertainty color, supporting both continuous and discrete modes.

Parameters:

depth (int): The depth of the color tree. color_u (np.ndarray): RGB color for uncertainty. cmap (str): Matplotlib colormap name for leaf nodes (required). v_min, v_max, u_min, u_max (float): Ranges for value and uncertainty. invert_u (bool): If False (default), high uncertainty maps to root (uncertainty color); if True, low uncertainty maps to root. colormap (mpl.colors.Colormap): Resampled colormap. nodes (np.ndarray): Array of RGB colors for tree nodes.

create_tree()[source]

Builds the color tree by interpolating colors at each node based on depth and value using the colormap and uncertainty color.

get_color(value, uncertainty, debug_print=False)[source]

Retrieve the color for a given value and uncertainty based on the color tree.

Parameters:

value (float): The primary value (e.g., data point value). uncertainty (float): The uncertainty level. debug_print (bool): If True, print debug information.

Returns:

np.ndarray:

RGB color array.

get_colors(image, show_uncertainty=True, discrete=False, continuous_leaves=False)[source]

Generates colors for an image array based on uncertainty (first channel) and value (second channel).

Parameters:

image (np.ndarray):

Input array with shape (…, 2), where last dim is [uncertainty, value].

show_uncertainty (bool):

If False, ignores uncertainty and uses colormap directly.

discrete (bool):

If True, treats as discrete levels using the tree.

continuous_leaves (bool):

If True and discrete=True, uses colormap interpolation at leaf level instead of tree nodes.

Returns:

np.ndarray:

RGB color array with shape (…, 3).

set_invert_u(invert)[source]

Sets whether to invert the uncertainty mapping.

update_colors(color_u=None)[source]

Updates the uncertainty color and rebuilds the tree if it changes.

update_ranges(v_min=None, v_max=None, u_min=None, u_max=None)[source]

Updates the value and uncertainty ranges.

Module contents

Core Colors Module

This module contains core color functionality including color interpolation and tree structures. These are fundamental color operations used across the UVisBox package.