colormap#

colormap_lookup_table([scale_range, ...])

Lookup table for the colormap.

cc(na, nd)

ss(na, nd)

boys2rgb(v)

boys 2 rgb cool colormap

orient2rgb(v)

Get Standard orientation 2 rgb colormap.

line_colors(streamlines[, cmap])

Create colors for streamlines to be used in actor.line.

get_cmap(name)

Make a callable, similar to maptlotlib.pyplot.get_cmap.

create_colormap(v[, name, auto])

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.

distinguishable_colormap([bg, exclude, ...])

Generate colors that are maximally perceptually distinct.

hex_to_rgb(color)

Converts Hexadecimal color code to rgb()

rgb2hsv(rgb)

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.

hsv2rgb(hsv)

HSV to RGB color space conversion.

xyz_from_rgb

ndarray(shape, dtype=float, buffer=None, offset=0,

rgb_from_xyz

ndarray(shape, dtype=float, buffer=None, offset=0,

xyz2rgb(xyz)

XYZ to RGB color space conversion.

rgb2xyz(rgb)

RGB to XYZ color space conversion.

get_xyz_coords(illuminant, observer)

Get the XYZ coordinates of the given illuminant and observer [1]_.

xyz2lab(xyz[, illuminant, observer])

XYZ to CIE-LAB color space conversion.

lab2xyz(lab[, illuminant, observer])

CIE-LAB to XYZcolor space conversion.

rgb2lab(rgb[, illuminant, observer])

Conversion from the sRGB color space (IEC 61966-2-1:1999) to the CIE Lab colorspace under the given illuminant and observer.

lab2rgb(lab[, illuminant, observer])

Lab to RGB color space conversion.

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 minimum 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

cc#

fury.colormap.cc(na, nd)[source]#

ss#

fury.colormap.ss(na, nd)[source]#

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)

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)

line_colors#

fury.colormap.line_colors(streamlines, cmap='rgb_standard')[source]#

Create colors for streamlines to be used in actor.line.

Parameters:
  • streamlines (sequence of ndarrays) –

  • cmap (('rgb_standard', 'boys_standard')) –

Returns:

colors

Return type:

ndarray

get_cmap#

fury.colormap.get_cmap(name)[source]#

Make a callable, similar to maptlotlib.pyplot.get_cmap.

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).

hex_to_rgb#

fury.colormap.hex_to_rgb(color)[source]#

Converts Hexadecimal color code to rgb()

color : string containing 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)

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.

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.

xyz_from_rgb#

fury.colormap.xyz_from_rgb()#
ndarray(shape, dtype=float, buffer=None, offset=0,

strides=None, order=None)

An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)

Arrays should be constructed using array, zeros or empty (refer to the See Also section below). The parameters given here refer to a low-level method (ndarray(…)) for instantiating an array.

For more information, refer to the numpy module and examine the methods and attributes of an array.

Parameters:
  • below) ((for the __new__ method; see Notes) –

  • shape (tuple of ints) – Shape of created array.

  • dtype (data-type, optional) – Any object that can be interpreted as a numpy data type.

  • buffer (object exposing buffer interface, optional) – Used to fill the array with data.

  • offset (int, optional) – Offset of array data in buffer.

  • strides (tuple of ints, optional) – Strides of data in memory.

  • order ({'C', 'F'}, optional) – Row-major (C-style) or column-major (Fortran-style) order.

fury.colormap.T#

Transpose of the array.

Type:

ndarray

fury.colormap.data#

The array’s elements, in memory.

Type:

buffer

fury.colormap.dtype#

Describes the format of the elements in the array.

Type:

dtype object

fury.colormap.flags#

Dictionary containing information related to memory use, e.g., ‘C_CONTIGUOUS’, ‘OWNDATA’, ‘WRITEABLE’, etc.

Type:

dict

fury.colormap.flat#

Flattened version of the array as an iterator. The iterator allows assignments, e.g., x.flat = 3 (See ndarray.flat for assignment examples; TODO).

Type:

numpy.flatiter object

fury.colormap.imag#

Imaginary part of the array.

Type:

ndarray

fury.colormap.real#

Real part of the array.

Type:

ndarray

fury.colormap.size#

Number of elements in the array.

Type:

int

fury.colormap.itemsize#

The memory use of each array element in bytes.

Type:

int

fury.colormap.nbytes#

The total number of bytes required to store the array data, i.e., itemsize * size.

Type:

int

fury.colormap.ndim#

The array’s number of dimensions.

Type:

int

fury.colormap.shape#

Shape of the array.

Type:

tuple of ints

fury.colormap.strides#

The step-size required to move from one element to the next in memory. For example, a contiguous (3, 4) array of type int16 in C-order has strides (8, 2). This implies that to move from element to element in memory requires jumps of 2 bytes. To move from row-to-row, one needs to jump 8 bytes at a time (2 * 4).

Type:

tuple of ints

fury.colormap.ctypes#

Class containing properties of the array needed for interaction with ctypes.

Type:

ctypes object

fury.colormap.base#

If the array is a view into another array, that array is its base (unless that array is also a view). The base array is where the array data is actually stored.

Type:

ndarray

See also

array

Construct an array.

zeros

Create an array, each element of which is zero.

empty

Create an array, but leave its allocated memory unchanged (i.e., it contains “garbage”).

dtype

Create a data-type.

numpy.typing.NDArray

An ndarray alias generic w.r.t. its dtype.type <numpy.dtype.type>.

Notes

There are two modes of creating an array using __new__:

  1. If buffer is None, then only shape, dtype, and order are used.

  2. If buffer is an object exposing the buffer interface, then all keywords are interpreted.

No __init__ method is needed because the array is fully initialized after the __new__ method.

Examples

These examples illustrate the low-level ndarray constructor. Refer to the See Also section above for easier ways of constructing an ndarray.

First mode, buffer is None:

>>> np.ndarray(shape=(2,2), dtype=float, order='F')
array([[0.0e+000, 0.0e+000], # random
       [     nan, 2.5e-323]])

Second mode:

>>> np.ndarray((2,), buffer=np.array([1,2,3]),
...            offset=np.int_().itemsize,
...            dtype=int) # offset = 1*itemsize, i.e. skip first element
array([2, 3])

rgb_from_xyz#

fury.colormap.rgb_from_xyz()#
ndarray(shape, dtype=float, buffer=None, offset=0,

strides=None, order=None)

An array object represents a multidimensional, homogeneous array of fixed-size items. An associated data-type object describes the format of each element in the array (its byte-order, how many bytes it occupies in memory, whether it is an integer, a floating point number, or something else, etc.)

Arrays should be constructed using array, zeros or empty (refer to the See Also section below). The parameters given here refer to a low-level method (ndarray(…)) for instantiating an array.

For more information, refer to the numpy module and examine the methods and attributes of an array.

Parameters:
  • below) ((for the __new__ method; see Notes) –

  • shape (tuple of ints) – Shape of created array.

  • dtype (data-type, optional) – Any object that can be interpreted as a numpy data type.

  • buffer (object exposing buffer interface, optional) – Used to fill the array with data.

  • offset (int, optional) – Offset of array data in buffer.

  • strides (tuple of ints, optional) – Strides of data in memory.

  • order ({'C', 'F'}, optional) – Row-major (C-style) or column-major (Fortran-style) order.

fury.colormap.T#

Transpose of the array.

Type:

ndarray

fury.colormap.data#

The array’s elements, in memory.

Type:

buffer

fury.colormap.dtype#

Describes the format of the elements in the array.

Type:

dtype object

fury.colormap.flags#

Dictionary containing information related to memory use, e.g., ‘C_CONTIGUOUS’, ‘OWNDATA’, ‘WRITEABLE’, etc.

Type:

dict

fury.colormap.flat#

Flattened version of the array as an iterator. The iterator allows assignments, e.g., x.flat = 3 (See ndarray.flat for assignment examples; TODO).

Type:

numpy.flatiter object

fury.colormap.imag#

Imaginary part of the array.

Type:

ndarray

fury.colormap.real#

Real part of the array.

Type:

ndarray

fury.colormap.size#

Number of elements in the array.

Type:

int

fury.colormap.itemsize#

The memory use of each array element in bytes.

Type:

int

fury.colormap.nbytes#

The total number of bytes required to store the array data, i.e., itemsize * size.

Type:

int

fury.colormap.ndim#

The array’s number of dimensions.

Type:

int

fury.colormap.shape#

Shape of the array.

Type:

tuple of ints

fury.colormap.strides#

The step-size required to move from one element to the next in memory. For example, a contiguous (3, 4) array of type int16 in C-order has strides (8, 2). This implies that to move from element to element in memory requires jumps of 2 bytes. To move from row-to-row, one needs to jump 8 bytes at a time (2 * 4).

Type:

tuple of ints

fury.colormap.ctypes#

Class containing properties of the array needed for interaction with ctypes.

Type:

ctypes object

fury.colormap.base#

If the array is a view into another array, that array is its base (unless that array is also a view). The base array is where the array data is actually stored.

Type:

ndarray

See also

array

Construct an array.

zeros

Create an array, each element of which is zero.

empty

Create an array, but leave its allocated memory unchanged (i.e., it contains “garbage”).

dtype

Create a data-type.

numpy.typing.NDArray

An ndarray alias generic w.r.t. its dtype.type <numpy.dtype.type>.

Notes

There are two modes of creating an array using __new__:

  1. If buffer is None, then only shape, dtype, and order are used.

  2. If buffer is an object exposing the buffer interface, then all keywords are interpreted.

No __init__ method is needed because the array is fully initialized after the __new__ method.

Examples

These examples illustrate the low-level ndarray constructor. Refer to the See Also section above for easier ways of constructing an ndarray.

First mode, buffer is None:

>>> np.ndarray(shape=(2,2), dtype=float, order='F')
array([[0.0e+000, 0.0e+000], # random
       [     nan, 2.5e-323]])

Second mode:

>>> np.ndarray((2,), buffer=np.array([1,2,3]),
...            offset=np.int_().itemsize,
...            dtype=int) # offset = 1*itemsize, i.e. skip first element
array([2, 3])

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.

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.

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.

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.

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.

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.

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.