phasorpy.color#
Color palettes and manipulation.
- phasorpy.color.float2int(rgb, /, dtype=<class 'numpy.uint8'>)[source]#
Return normalized color components as integer type.
- 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
.
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).
Wavelength values are clipped to 360..750, rounded, and used to index the
SRGB_SPECTRUM
palette.- Parameters:
wavelength (array_like) – Scalar or array of wavelength(s) to convert.
dtype (data-type, optional) – Data-type of return value. The default is
float32
.
- Returns:
Approximate sRGB color components of visible wavelength. Floating-point types are in range 0.0 to 1.0. Integer types 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)