colorimetry.core#

Colorimetry calculation engine. Handles spectral interpolation, XYZ calculation, and sRGB conversions. Uses the optiland backend for mathematical operations.

Functions

spectrum_to_xyz(wavelengths, values[, ...])

Converts a spectrum (R or T) to CIE XYZ coordinates.

xyz_to_srgb(X[, Y, Z])

Converts XYZ (Y=100 max) to sRGB (0-255).

xyz_to_xyY(X[, Y, Z])

Converts XYZ to xyY (chromaticity + luminance).

spectrum_to_xyz(wavelengths: list[float], values: list[float], illuminant: list[float] | None = None, observer: str = '2deg') tuple[float, float, float][source]#

Converts a spectrum (R or T) to CIE XYZ coordinates.

References

  • CIE 15:2004 Colorimetry, 3rd Edition.

  • ISO 11664-3:2019 (CIE S 014-3/E:2011) Colorimetry — Part 3: CIE Tristimulus Values.

Parameters:
  • wavelengths – List of wavelengths of the measured spectrum (in nm).

  • values – Spectral values (0.0 to 1.0).

  • illuminant – Illuminant spectrum aligned with WAVELENGTHS_STD. Default: D65.

  • observer – ‘2deg’ (CIE 1931) or ‘10deg’ (CIE 1964).

Returns:

(X, Y, Z) normalized (Y=100 for a perfect white).

xyz_to_srgb(X: float | Any, Y: float | Any | None = None, Z: float | Any | None = None) tuple[Any, Any, Any][source]#

Converts XYZ (Y=100 max) to sRGB (0-255). Vectorized: supports scalars, separate arrays, or a single packed array with a dimension of size 3. Uses the standard sRGB matrix (D65) and sRGB Gamma correction.

References

  • IEC 61966-2-1:1999 Multimedia systems and equipment - Colour measurement and management - Part 2-1: Colour management - Default RGB colour space - sRGB.

  • Anderson, M., Motta, R., Chandrasekar, S., & Stokes, M. (1996). Proposal for a Standard Default Color Space for the Internet—sRGB.

xyz_to_xyY(X: float | Any, Y: float | Any | None = None, Z: float | Any | None = None) tuple[Any, Any, Any][source]#

Converts XYZ to xyY (chromaticity + luminance). Vectorized: supports scalars, separate arrays, or a single packed array with a dimension of size 3.