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)
phasorpy.color.CATEGORICAL#

Categorical sRGB color palette inspired by C Glasbey.

The palette contains 64 maximally distinct colours.

Generated with the glasbey package:

import glasbey; numpy.array(glasbey.create_palette(64, as_hex=False))
phasorpy.color.CATEGORICAL
phasorpy.color.SRGB_SPECTRUM#

sRGB color components for visible light wavelengths 360-750 nm.

Based on the CIE 1931 2° Standard Observer.

Generated with the colour package:

import colour; colour.plotting.plot_visible_spectrum()
phasorpy.color.SRGB_SPECTRUM