colormap
¶
|
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. |
|
Converts Hexadecimal color code to rgb() |
|
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. |
|
|
Issue a warning, or maybe ignore it or raise an exception. |
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)
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
vtkLookupTable
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, 10] 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¶
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)
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)