phasorpy.color#
Color palettes and color manipulation utilities.
- 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 (dtype_like, 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 the 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 (dtype_like, optional) – Data-type of return value. The default is
float32
.
- Returns:
Approximate sRGB color components of visible wavelength(s). If input is scalar, return tuple of three floats. If input is array, return ndarray with shape (…, 3). 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 of float
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 colors 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).
Array of shape (391, 3) containing normalized sRGB color components for wavelengths from 360 to 750 nm in 1 nm increments. Based on the CIE 1931 2° Standard Observer.
Generated using the colour package:
import colour; colour.plotting.plot_visible_spectrum()
