colormap
#
An array object represents a multidimensional, homogeneous array of fixed-size items. |
|
An array object represents a multidimensional, homogeneous array of fixed-size items. |
|
|
Lookup table for the colormap. |
|
|
|
|
|
Boys 2 rgb cool colormap |
|
Get Standard orientation 2 rgb colormap. |
|
Create colors for streamlines to be used in actor.line. |
|
Make a callable, similar to maptlotlib.pyplot.get_cmap. |
|
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. |
|
Converts Hexadecimal color code to rgb() |
|
RGB to HSV color space conversion. |
|
HSV to RGB color space conversion. |
|
XYZ to RGB color space conversion. |
|
RGB to XYZ color space conversion. |
|
Get the XYZ coordinates of the given illuminant and observer [1]. |
|
XYZ to CIE-LAB color space conversion. |
|
CIE-LAB to XYZcolor space conversion. |
|
Conversion from the sRGB color space (IEC 61966-2-1:1999) to the CIE Lab colorspace under the given illuminant and observer. |
|
Lab to RGB color space conversion. |
xyz_from_rgb#
- fury.colormap.xyz_from_rgb#
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:
- (for the __new__ method; see Notes below)
- shapetuple of ints
Shape of created array.
- dtypedata-type, optional
Any object that can be interpreted as a numpy data type.
- bufferobject exposing buffer interface, optional
Used to fill the array with data.
- offsetint, optional
Offset of array data in buffer.
- stridestuple of ints, optional
Strides of data in memory.
- order{‘C’, ‘F’}, optional
Row-major (C-style) or column-major (Fortran-style) order.
- Attributes:
- Tndarray
Transpose of the array.
- databuffer
The array’s elements, in memory.
- dtypedtype object
Describes the format of the elements in the array.
- flagsdict
Dictionary containing information related to memory use, e.g., ‘C_CONTIGUOUS’, ‘OWNDATA’, ‘WRITEABLE’, etc.
- flatnumpy.flatiter object
Flattened version of the array as an iterator. The iterator allows assignments, e.g.,
x.flat = 3
(See ndarray.flat for assignment examples; TODO).- imagndarray
Imaginary part of the array.
- realndarray
Real part of the array.
- sizeint
Number of elements in the array.
- itemsizeint
The memory use of each array element in bytes.
- nbytesint
The total number of bytes required to store the array data, i.e.,
itemsize * size
.- ndimint
The array’s number of dimensions.
- shapetuple of ints
Shape of the array.
- stridestuple of ints
The step-size required to move from one element to the next in memory. For example, a contiguous
(3, 4)
array of typeint16
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
).- ctypesctypes object
Class containing properties of the array needed for interaction with ctypes.
- basendarray
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.
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__
:If buffer is None, then only shape, dtype, and order are used.
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#
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:
- (for the __new__ method; see Notes below)
- shapetuple of ints
Shape of created array.
- dtypedata-type, optional
Any object that can be interpreted as a numpy data type.
- bufferobject exposing buffer interface, optional
Used to fill the array with data.
- offsetint, optional
Offset of array data in buffer.
- stridestuple of ints, optional
Strides of data in memory.
- order{‘C’, ‘F’}, optional
Row-major (C-style) or column-major (Fortran-style) order.
- Attributes:
- Tndarray
Transpose of the array.
- databuffer
The array’s elements, in memory.
- dtypedtype object
Describes the format of the elements in the array.
- flagsdict
Dictionary containing information related to memory use, e.g., ‘C_CONTIGUOUS’, ‘OWNDATA’, ‘WRITEABLE’, etc.
- flatnumpy.flatiter object
Flattened version of the array as an iterator. The iterator allows assignments, e.g.,
x.flat = 3
(See ndarray.flat for assignment examples; TODO).- imagndarray
Imaginary part of the array.
- realndarray
Real part of the array.
- sizeint
Number of elements in the array.
- itemsizeint
The memory use of each array element in bytes.
- nbytesint
The total number of bytes required to store the array data, i.e.,
itemsize * size
.- ndimint
The array’s number of dimensions.
- shapetuple of ints
Shape of the array.
- stridestuple of ints
The step-size required to move from one element to the next in memory. For example, a contiguous
(3, 4)
array of typeint16
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
).- ctypesctypes object
Class containing properties of the array needed for interaction with ctypes.
- basendarray
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.
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__
:If buffer is None, then only shape, dtype, and order are used.
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])
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_rangetuple
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_rangetuple of floats
HSV values (min 0 and max 1). Default is (0.8, 0).
- saturation_rangetuple of floats
HSV values (min 0 and max 1). Default is (1, 1).
- value_rangetuple of floats
HSV value (min 0 and max 1). Default is (0.8, 0.8).
- Returns:
- lookup_tableLookupTable
cc#
ss#
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:
- varray, 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:
- carray, shape (N, 3) matrix of rgb colors corresponding to the vectors
given in V.
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:
- carray, shape (N, 3) matrix of rgb colors corresponding to the vectors
given in V.
Examples
>>> from fury import colormap >>> v = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) >>> c = colormap.orient2rgb(v)
line_colors#
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
- namestr.
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.
- autobool,
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=None, 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:
- bgtuple (optional)
Background RGB color, to make sure that your colors are also distinguishable from the background. Default: (0, 0, 0).
- excludelist of tuples (optional)
Additional RGB colors to be distinguishable from.
- nb_colorsint (optional)
Number of colors desired. Default: generate as many colors as needed.
- Returns:
- iterable of ndarray
If nb_colors is provided, returns a list of RBG colors. Otherwise, yields the next RBG color maximally perceptually distinct from previous ones.
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).
Examples
>>> from fury.colormap import distinguishable_colormap >>> # Generate 5 colors >>> _ = [c for i, c in zip(range(5), distinguishable_colormap())]
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:
- carray, shape(1, 3) matrix of rbg colors corresponding to the
hexcode string given in color.
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.
- Parameters:
- rgb(…, 3, …) array_like
The image in RGB format. By default, the final dimension denotes channels.
- Returns:
- out(…, 3, …) ndarray
The image in HSV format. Same dimensions as input.
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(…, 3, …) ndarray
The image in RGB format. Same dimensions as input.
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(…, 3, …) ndarray
The image in RGB format. Same dimensions as input.
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(…, 3, …) ndarray
The image in XYZ format. Same dimensions as input.
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:
- outarray
Array with 3 elements containing the XYZ coordinates of the given illuminant.
Notes
Original Implementation from scikit-image package. it can be found here: scikit-image/scikit-image This implementation might have been modified.
References
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(…, 3, …) ndarray
The image in CIE-LAB format. Same dimensions as input.
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(…, 3, …) ndarray
The image in XYZ format. Same dimensions as input.
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(…, 3, …) ndarray
The image in Lab format. Same dimensions as input.
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(…, 3, …) ndarray
The image in RGB format. Same dimensions as input.
Notes
Original Implementation from scikit-image package. it can be found at: scikit-image/scikit-image This implementation might have been modified.