Function Repository Resource:

CIEColorMatchingFunctionValues

Source Notebook

Evaluate the CIE color matching functions for a given wavelength

Contributed by: Jan Mangaldan

ResourceFunction["CIEColorMatchingFunctionValues"][λ]

evaluates the CIE color matching functions for a given wavelength λ.

Details

The color matching functions are also referred to as the standard (colorimetric) observer.
The color matching functions are functions defined by the International Commission on Illumination (CIE) to represent an average human's chromatic response within a 2° arc inside the fovea.
λ can be a Quantity object with compatible length units.
If λ is given as a number, its unit is assumed to be in nanometers.

Examples

Basic Examples (2) 

Evaluate the color matching functions for a given wavelength:

In[1]:=
ResourceFunction["CIEColorMatchingFunctionValues"][589]
Out[1]=

Get the corresponding color:

In[2]:=
XYZColor[%]
Out[2]=

Plot the color matching functions:

In[3]:=
Plot[ResourceFunction[
  "CIEColorMatchingFunctionValues"][\[Lambda]], {\[Lambda], 385, 745}]
Out[3]=

Scope (2) 

Use any Quantity with length units:

In[4]:=
ResourceFunction["CIEColorMatchingFunctionValues"][
 Quantity[5500, "Angstroms"]]
Out[4]=

Get the corresponding color:

In[5]:=
XYZColor[%]
Out[5]=

CIEColorMatchingFunctionValues threads over lists:

In[6]:=
ResourceFunction["CIEColorMatchingFunctionValues"][{400, 500, 600}]
Out[6]=

Properties and Relations (1) 

Compare the color obtained from CIEColorMatchingFunctionValues with the color obtained from ColorData["VisibleSpectrum"]. There are slight differences, for example a narrower red band:

In[7]:=
DensityPlot[\[Lambda], {\[Lambda], 385, 745}, {y, 0, 50}, ColorFunction -> Function[t, XYZColor[ResourceFunction["CIEColorMatchingFunctionValues"][t]]], ColorFunctionScaling -> False, AspectRatio -> Automatic, FrameTicks -> {Automatic, None}]
Out[7]=
In[8]:=
DensityPlot[\[Lambda], {\[Lambda], 385, 745}, {y, 0, 50}, ColorFunction -> Function[t, ColorData["VisibleSpectrum", t]], ColorFunctionScaling -> False, AspectRatio -> Automatic, FrameTicks -> {Automatic, None}]
Out[8]=

Possible Issues (2) 

CIEColorMatchingFunctionValues is left unevaluated if the argument is a quantity with incompatible units:

In[9]:=
ResourceFunction["CIEColorMatchingFunctionValues"][
 Quantity[7.*^14, "Hertz"]]
Out[9]=

Convert frequency to wavelength before giving it to CIEColorMatchingFunctionValues:

In[10]:=
ResourceFunction["CIEColorMatchingFunctionValues"][
 Quantity["SpeedOfLight"]/Quantity[7.*^14, "Hertz"]]
Out[10]=

Version History

  • 1.0.0 – 08 January 2021

Source Metadata

Related Resources

Author Notes

The coefficients used in this implementation are different from the ones in the Wyman et al. paper. They were first used in https://mathematica.stackexchange.com/a/86962, and were determined using Mathematica's NMinimize.

License Information