colormap
#
alias of |
|
|
boys 2 rgb cool colormap |
|
|
|
Lookup table for the colormap. |
|
Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value. |
|
Generate colors that are maximally perceptually distinct. |
|
Make a callable, similar to maptlotlib.pyplot.get_cmap. |
|
Get the XYZ coordinates of the given illuminant and observer [1]_. |
|
Converts Hexadecimal color code to rgb() |
|
HSV to RGB color space conversion. |
|
Lab to RGB color space conversion. |
|
CIE-LAB to XYZcolor space conversion. |
|
Create colors for streamlines to be used in actor.line. |
|
Return package-like thing and module setup for package name. |
|
Get Standard orientation 2 rgb colormap. |
|
Join two or more pathname components, inserting '/' as needed. |
|
RGB to HSV color space conversion. :param rgb: The image in RGB format. By default, the final dimension denotes channels. :type rgb: (..., 3, ...) array_like. |
|
Conversion from the sRGB color space (IEC 61966-2-1:1999) to the CIE Lab colorspace under the given illuminant and observer. |
|
RGB to XYZ color space conversion. |
|
|
|
Issue a warning, or maybe ignore it or raise an exception. |
|
XYZ to CIE-LAB color space conversion. |
|
XYZ to RGB color space conversion. |
LookupTable
#
- fury.colormap.LookupTable#
alias of
vtkLookupTable
boys2rgb#
- fury.colormap.boys2rgb(v)[source]#
boys 2 rgb cool colormap
Maps a given field of undirected lines (line field) to rgb colors using Boy’s Surface immersion of the real projective plane. Boy’s Surface is one of the three possible surfaces obtained by gluing a Mobius strip to the edge of a disk. The other two are the crosscap and Roman surface, Steiner surfaces that are homeomorphic to the real projective plane (Pinkall 1986). The Boy’s surface is the only 3D immersion of the projective plane without singularities. Visit http://www.cs.brown.edu/~cad/rp2coloring for further details. Cagatay Demiralp, 9/7/2008.
Code was initially in matlab and was rewritten in Python for fury by the FURY Team. Thank you Cagatay for putting this online.
- Parameters:
v (array, shape (N, 3) of unit vectors (e.g., principal eigenvectors of) – tensor data) representing one of the two directions of the undirected lines in a line field.
- Returns:
c – given in V.
- Return type:
array, shape (N, 3) matrix of rgb colors corresponding to the vectors
Examples
>>> from fury import colormap >>> v = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) >>> c = colormap.boys2rgb(v)
cc#
colormap_lookup_table#
- fury.colormap.colormap_lookup_table(scale_range=(0, 1), hue_range=(0.8, 0), saturation_range=(1, 1), value_range=(0.8, 0.8))[source]#
Lookup table for the colormap.
- Parameters:
scale_range (tuple) – It can be anything e.g. (0, 1) or (0, 255). Usually it is the mininum and maximum value of your data. Default is (0, 1).
hue_range (tuple of floats) – HSV values (min 0 and max 1). Default is (0.8, 0).
saturation_range (tuple of floats) – HSV values (min 0 and max 1). Default is (1, 1).
value_range (tuple of floats) – HSV value (min 0 and max 1). Default is (0.8, 0.8).
- Returns:
lookup_table
- Return type:
LookupTable
create_colormap#
- fury.colormap.create_colormap(v, name='plasma', auto=True)[source]#
Create colors from a specific colormap and return it as an array of shape (N,3) where every row gives the corresponding r,g,b value. The colormaps we use are similar with those of matplotlib.
- Parameters:
v ((N,) array) – vector of values to be mapped in RGB colors according to colormap
name (str.) – Name of the colormap. Currently implemented: ‘jet’, ‘blues’, ‘accent’, ‘bone’ and matplotlib colormaps if you have matplotlib installed. For example, we suggest using ‘plasma’, ‘viridis’ or ‘inferno’. ‘jet’ is popular but can be often misleading and we will deprecate it the future.
auto (bool,) – if auto is True then v is interpolated to [0, 1] from v.min() to v.max()
Notes
FURY supports a few colormaps for those who do not use Matplotlib, for more colormaps consider downloading Matplotlib (see matplotlib.org).
distinguishable_colormap#
- fury.colormap.distinguishable_colormap(bg=(0, 0, 0), exclude=[], nb_colors=None)[source]#
Generate colors that are maximally perceptually distinct.
This function generates a set of colors which are distinguishable by reference to the “Lab” color space, which more closely matches human color perception than RGB. Given an initial large list of possible colors, it iteratively chooses the entry in the list that is farthest (in Lab space) from all previously-chosen entries. While this “greedy” algorithm does not yield a global maximum, it is simple and efficient. Moreover, the sequence of colors is consistent no matter how many you request, which facilitates the users’ ability to learn the color order and avoids major changes in the appearance of plots when adding or removing lines.
- Parameters:
bg (tuple (optional)) – Background RGB color, to make sure that your colors are also distinguishable from the background. Default: (0, 0, 0).
exclude (list of tuples (optional)) – Additional RGB colors to be distinguishable from.
nb_colors (int (optional)) – Number of colors desired. Default: generate as many colors as needed.
- Returns:
If nb_colors is provided, returns a list of RBG colors. Otherwise, yields the next RBG color maximally perceptually distinct from previous ones.
- Return type:
iterable of ndarray
Examples
>>> from dipy.viz.colormap import distinguishable_colormap >>> # Generate 5 colors >>> [c for i, c in zip(range(5), distinguishable_colormap())] [array([ 0., 1., 0.]), array([ 1., 0., 1.]), array([ 1. , 0.75862069, 0.03448276]), array([ 0. , 1. , 0.89655172]), array([ 0. , 0.17241379, 1. ])]
Notes
Code was initially in matlab and was rewritten in Python for dipy by the Dipy Team. Thank you Tim Holy for putting this online. Visit http://www.mathworks.com/matlabcentral/fileexchange/29702 for the original implementation (v1.2), 14 Dec 2010 (Updated 07 Feb 2011).
get_cmap#
get_xyz_coords#
- fury.colormap.get_xyz_coords(illuminant, observer)[source]#
Get the XYZ coordinates of the given illuminant and observer [1]_.
- Parameters:
illuminant ({"A", "B", "C", "D50", "D55", "D65", "D75", "E"}, optional) – The name of the illuminant (the function is NOT case sensitive).
observer ({"2", "10", "R"}, optional) – One of: 2-degree observer, 10-degree observer, or ‘R’ observer as in R function grDevices::convertColor.
- Returns:
out – Array with 3 elements containing the XYZ coordinates of the given illuminant.
- Return type:
array
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.
hex_to_rgb#
- fury.colormap.hex_to_rgb(color)[source]#
Converts Hexadecimal color code to rgb()
color : string containting hexcode of color (can also start with a hash)
- Returns:
c – hexcode string given in color.
- Return type:
array, shape(1, 3) matrix of rbg colors corresponding to the
Examples
>>> from fury import colormap >>> color = "#FFFFFF" >>> c = colormap.hex_to_rgb(color)
>>> from fury import colormap >>> color = "FFFFFF" >>> c = colormap.hex_to_rgb(color)
hsv2rgb#
- fury.colormap.hsv2rgb(hsv)[source]#
HSV to RGB color space conversion.
- Parameters:
hsv ((..., 3, ...) array_like) – The image in HSV format. By default, the final dimension denotes channels.
- Returns:
out – The image in RGB format. Same dimensions as input.
- Return type:
(…, 3, …) ndarray
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.
lab2rgb#
- fury.colormap.lab2rgb(lab, illuminant='D65', observer='2')[source]#
Lab to RGB color space conversion.
- Parameters:
lab ((..., 3, ...) array_like) – The image in Lab format. By default, the final dimension denotes channels.
illuminant ({"A", "B", "C", "D50", "D55", "D65", "D75", "E"}, optional) – The name of the illuminant (the function is NOT case sensitive).
observer ({"2", "10", "R"}, optional) – The aperture angle of the observer.
- Returns:
out – The image in RGB format. Same dimensions as input.
- Return type:
(…, 3, …) ndarray
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.
lab2xyz#
- fury.colormap.lab2xyz(lab, illuminant='D65', observer='2')[source]#
CIE-LAB to XYZcolor space conversion.
- Parameters:
lab ((..., 3, ...) array_like) – The image in Lab format. By default, the final dimension denotes channels.
illuminant ({"A", "B", "C", "D50", "D55", "D65", "D75", "E"}, optional) – The name of the illuminant (the function is NOT case-sensitive).
observer ({"2", "10", "R"}, optional) – The aperture angle of the observer.
- Returns:
out – The image in XYZ format. Same dimensions as input.
- Return type:
(…, 3, …) ndarray
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.
line_colors#
optional_package#
- fury.colormap.optional_package(name, trip_msg=None)[source]#
Return package-like thing and module setup for package name.
- Parameters:
- Returns:
pkg_like (module or
TripWire
instance) – If we can import the package, return it. Otherwise return an object raising an error when accessedhave_pkg (bool) – True if import for package was successful, false otherwise
module_setup (function) – callable usually set as
setup_module
in calling namespace, to allow skipping tests.
Examples
Typical use would be something like this at the top of a module using an optional package: >>> from fury.optpkg import optional_package >>> pkg, have_pkg, setup_module = optional_package(‘not_a_package’) Of course in this case the package doesn’t exist, and so, in the module: >>> have_pkg False and >>> pkg.some_function() #doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): … TripWireError: We need package not_a_package for these functions, but
import not_a_package
raised an ImportError If the module does exist - we get the module >>> pkg, _, _ = optional_package(‘os’) >>> hasattr(pkg, ‘path’) True Or a submodule if that’s what we asked for >>> subpkg, _, _ = optional_package(‘os.path’) >>> hasattr(subpkg, ‘dirname’) True
orient2rgb#
- fury.colormap.orient2rgb(v)[source]#
Get Standard orientation 2 rgb colormap.
v : array, shape (N, 3) of vectors not necessarily normalized
- Returns:
c – given in V.
- Return type:
array, shape (N, 3) matrix of rgb colors corresponding to the vectors
Examples
>>> from fury import colormap >>> v = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) >>> c = colormap.orient2rgb(v)
pjoin#
- fury.colormap.pjoin(a, *p)#
Join two or more pathname components, inserting ‘/’ as needed. If any component is an absolute path, all previous path components will be discarded. An empty last part will result in a path that ends with a separator.
rgb2hsv#
- fury.colormap.rgb2hsv(rgb)[source]#
RGB to HSV color space conversion. :param rgb: The image in RGB format. By default, the final dimension denotes
channels.
- Returns:
out – The image in HSV format. Same dimensions as input.
- Return type:
(…, 3, …) ndarray
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.
rgb2lab#
- fury.colormap.rgb2lab(rgb, illuminant='D65', observer='2')[source]#
Conversion from the sRGB color space (IEC 61966-2-1:1999) to the CIE Lab colorspace under the given illuminant and observer.
- Parameters:
rgb ((..., 3, ...) array_like) – The image in RGB format. By default, the final dimension denotes channels.
illuminant ({"A", "B", "C", "D50", "D55", "D65", "D75", "E"}, optional) – The name of the illuminant (the function is NOT case sensitive).
observer ({"2", "10", "R"}, optional) – The aperture angle of the observer.
- Returns:
out – The image in Lab format. Same dimensions as input.
- Return type:
(…, 3, …) ndarray
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.
rgb2xyz#
- fury.colormap.rgb2xyz(rgb)[source]#
RGB to XYZ color space conversion.
- Parameters:
rgb ((..., 3, ...) array_like) – The image in RGB format. By default, the final dimension denotes channels.
- Returns:
out – The image in XYZ format. Same dimensions as input.
- Return type:
(…, 3, …) ndarray
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.
ss#
warn#
- fury.colormap.warn(message, category=None, stacklevel=1, source=None)#
Issue a warning, or maybe ignore it or raise an exception.
xyz2lab#
- fury.colormap.xyz2lab(xyz, illuminant='D65', observer='2')[source]#
XYZ to CIE-LAB color space conversion.
- Parameters:
xyz ((..., 3, ...) array_like) – The image in XYZ format. By default, the final dimension denotes channels.
illuminant ({"A", "B", "C", "D50", "D55", "D65", "D75", "E"}, optional) – The name of the illuminant (the function is NOT case sensitive).
observer ({"2", "10", "R"}, optional) – One of: 2-degree observer, 10-degree observer, or ‘R’ observer as in R function grDevices::convertColor.
- Returns:
out – The image in CIE-LAB format. Same dimensions as input.
- Return type:
(…, 3, …) ndarray
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.
xyz2rgb#
- fury.colormap.xyz2rgb(xyz)[source]#
XYZ to RGB color space conversion.
- Parameters:
xyz ((..., 3, ...) array_like) – The image in XYZ format. By default, the final dimension denotes channels.
- Returns:
out – The image in RGB format. Same dimensions as input.
- Return type:
(…, 3, …) ndarray
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.