colour.colorimetry.tristimulus Module

Tristimulus Values

Defines objects for tristimulus values computation from spectral data.

colour.colorimetry.tristimulus.spectral_to_XYZ(spd, cmfs=<colour.colorimetry.cmfs.XYZ_ColourMatchingFunctions object at 0x102cf5c10>, illuminant=None)[source]

Converts given spectral power distribution to CIE XYZ colourspace using given colour matching functions and illuminant.

Parameters:
  • spd (SpectralPowerDistribution) – Spectral power distribution.
  • cmfs (XYZ_ColourMatchingFunctions) – Standard observer colour matching functions.
  • illuminant (SpectralPowerDistribution, optional) – Illuminant spectral power distribution.
Returns:

CIE XYZ colourspace matrix.

Return type:

ndarray, (3,)

Warning

The output domain of that definition is non standard!

Notes

  • Output CIE XYZ colourspace matrix is in domain [0, 100].

References

[1]Wyszecki & Stiles, Color Science - Concepts and Methods Data and Formulae - Second Edition, Wiley Classics Library Edition, published 2000, ISBN-10: 0-471-39918-3, page 158.

Examples

>>> from colour import CMFS, ILLUMINANTS_RELATIVE_SPDS, SpectralPowerDistribution  
>>> cmfs = CMFS.get('CIE 1931 2 Degree Standard Observer')
>>> data = {380: 0.0600, 390: 0.0600}
>>> spd = SpectralPowerDistribution('Custom', data)
>>> illuminant = ILLUMINANTS_RELATIVE_SPDS.get('D50')
>>> spectral_to_XYZ(spd, cmfs, illuminant)  
array([  4.5764852...e-04,   1.2964866...e-05,   2.1615807...e-03])
colour.colorimetry.tristimulus.wavelength_to_XYZ(*args, **kwds)[source]

Converts given wavelength \(\lambda\) to CIE XYZ colourspace using given colour matching functions.

If the wavelength \(\lambda\) is not available in the colour matching function, its value will be calculated using CIE recommendations: The method developed by Sprague (1880) should be used for interpolating functions having a uniformly spaced independent variable and a Cubic Spline method for non-uniformly spaced independent variable.

Parameters:
  • wavelength (numeric) – Wavelength \(\lambda\) in nm.
  • cmfs (XYZ_ColourMatchingFunctions, optional) – Standard observer colour matching functions.
Returns:

CIE XYZ colourspace matrix.

Return type:

ndarray, (3,)

Raises:

ValueError – If wavelength \(\lambda\) is not in the colour matching functions domain.

Notes

  • Output CIE XYZ colourspace matrix is in domain [0, 1].
  • If scipy is not unavailable the Cubic Spline method will fallback to legacy Linear interpolation.

Examples

>>> from colour import CMFS
>>> cmfs = CMFS.get('CIE 1931 2 Degree Standard Observer')
>>> wavelength_to_XYZ(480)  
array([ 0.09564  ,  0.13902  ,  0.812950...])