phasorpy.color#
Color palettes and manipulation.
- phasorpy.color.float2int(rgb, /, dtype=<class 'numpy.uint8'>)[source]#
Return normalized color components as integers.
- Parameters:
rgb (array_like) – Scalar or array of normalized floating-point color components.
dtype (data-type, optional) – Data type of return value. The default is
uint8
.
- Returns:
Color components as integers scaled to dtype’s range.
- Return type:
ndarray
Examples
>>> float2int([0.0, 0.5, 1.0]) array([ 0, 128, 255], dtype=uint8)
- phasorpy.color.wavelength2rgb(wavelength, /, dtype=None)[source]#
Return approximate sRGB color components of visible wavelength(s).
Wavelengths are clipped to range [360, 750] nm, rounded, and used to index the
SRGB_SPECTRUM
palette.- Parameters:
wavelength (array_like) – Scalar or array of wavelengths in nm.
dtype (data-type, optional) – Data-type of return value. The default is
float32
.
- Returns:
Approximate sRGB color components of visible wavelength. Floating-point values are in range [0.0, 1.0]. Integer values are scaled to the dtype’s maximum value.
- Return type:
ndarray or tuple
Examples
>>> wavelength2rgb(517.2, 'uint8') (0, 191, 0) >>> wavelength2rgb([517, 566], 'uint8') array([[ 0, 191, 0], [133, 190, 0]], dtype=uint8)
- phasorpy.color.CATEGORICAL#
Categorical sRGB color palette inspired by C. Glasbey.
Contains 64 maximally distinct colours for visualization.
Generated using the glasbey package:
import glasbey; numpy.array(glasbey.create_palette(64, as_hex=False))

- phasorpy.color.SRGB_SPECTRUM#
sRGB color components for wavelengths of visible light (360-750 nm).
Based on the CIE 1931 2° Standard Observer.
Generated using the colour package:
import colour; colour.plotting.plot_visible_spectrum()
