Color¶
Provides tools for color manipulation.
Note
All numerical color values are by default returned in the range [0,1].
-
color
(arg, alpha=None, as_int=False, int_type=<class 'int'>)[source]¶ Converts color arguent to rgb values
Arguments
- argobject
Color specifiction, e.g. a rgb tuple, color name from matplotlib or vispy, hex code
- alphaNone, bool or float
Include the alpha value in the rgb tuple. If None and an alpha value exists, it is kept, otherwise it is not included. If False the alpha value is not included. If True, the alpha value is included and set to 1 in case its not given in the input.
- as_intbool
If True, return colors as integers in range 0 to 255.
Returns
- rgblist of float or int
RBG or RGBA values for the colors.
-
color_map
(cmap=None, alpha=True, as_int=False, int_type=<class 'int'>)¶ Convert argument to a color map function.
Arguments
- cmapNone, string, tuple or list of colors
Color map specification. If a tuple is given a colormap that linearly interpolates is returned.
- alphaNone, bool, int or float
Include the alpha value in the color map.
- as_intbool
If True return color maps as integers in range 0 to 255.
- int_typedtype
The type to use for integer color maps.
Returns
- cmapfunction
A color map function that maps floats in [0,1] to a RBG or RGBA tuples.
-
colormap
(cmap=None, alpha=True, as_int=False, int_type=<class 'int'>)[source]¶ Convert argument to a color map function.
Arguments
- cmapNone, string, tuple or list of colors
Color map specification. If a tuple is given a colormap that linearly interpolates is returned.
- alphaNone, bool, int or float
Include the alpha value in the color map.
- as_intbool
If True return color maps as integers in range 0 to 255.
- int_typedtype
The type to use for integer color maps.
Returns
- cmapfunction
A color map function that maps floats in [0,1] to a RBG or RGBA tuples.
-
hex_to_rgb
(color, alpha=None, as_int=False)[source]¶ Return rgb color from hex code
Arguments
- colorstring
Hex code of the color
- alphaNone, bool, int or float
Include the alpha value in the rgb tuple. If None the alpha value is included if given in the hex code, if False no alpha value is given, if True the alpha value is included and set to 1 in case its not given in the input.
- as_intbool
If True return colors as integers in range 0 to 255.
Returns
- rgblist of float or int
RBG or RGBA values for the colors.
-
orientation_to_boys
(orientations, alpha=None, as_int=False)[source]¶ Colormap mapping 3d orientation vectors into rgb colors.
Arguments
- orientationsarray
List of 3d vectors as nx3 array
- alphaNone, bool, int or float
Include the alpha value in the color map.
- as_intbool
If True return color maps as integers in range 0 to 255.
Returns
- colorsarray
RGB colors for the oreitnation vectors according to Boys coloring.
Note
The Boys color map is a smooth way of coloring orientations.
-
orientation_to_rgb
(orientation, alpha=None, as_int=False)[source]¶ Color map mapping 3d orientation vectors into rgb colors using normalized coordinates.
Arguments
- orientationsarray
List of 3d vectors as nx3 array
- alphaNone, bool, int or float
Include the alpha value in the color map.
- as_intbool
If True return color maps as integers in range 0 to 255.
Returns
- colorsarray
RGB colors for the orientation vectors according to standard coloring.
Note
This color map is not continous.
-
rgb_LUT
()[source]¶ Returns a lookup table listing all integer rgb colors
Note
Useful to color data and plot in imagej.
-
rgb_to_LUT
(rgb)[source]¶ Converts the rgb colors to the index color in the full rgb color look up table
Arguments
- rgbarray
Integer rgb values as nX3 array
Returns
- indexarray
The indices of the rgb values in the full rgb LUT.
-
rgb_to_hex
(rgb, alpha=None, as_int=False)[source]¶ Return hex code from rgb or rgba colors
Arguments
- colortuple of int or float
Hex code of the color
- alphaNone, bool or float
Include the alpha value in the rgb tuple
- as_intbool
If True return colors as integers in range 0 to 255.
Returns
- rgblist of float or int
RBG or RGBA values for the colors.