XYZ tristimulus values are mathematical abstractions, not physical reality. Moreover, the XYZ and xyY color spaces are not perceptually uniform; the relationships between closelyspaced colors are not intuitive. A number of color spaces, such as Lab, have been derived from XYZ that are of more practical use. Lab (formally, CIE L*a*b*) is a coloropponent space with dimensions L* for lightness and a* and b* for the coloropponent dimensions, based on nonlinearly transformed XYZ coordinates.
The lightness, L*, represents black at L* = 0, and white at L* = 100. The color channels, a* and b*, will represent neutral gray values at a* = 0 and b* = 0. The red/green opponent colors are represented along the a* axis, with a cyangreen at negative values and a magentared at positive values. The yellow/blue opponent colors are represented along the b* axis, with blue at negative values and yellow at positive values.
The intention of the Lab color space is to create a space that can be computed via simple formulas from the XYZ space but is more perceptually uniform than XYZ. The nonlinear relations for L*, a*, and b* are intended to mimic the nonlinear response of the eye.
where
When converting XYZ to Lab, the tristimulus values must be scaled from a reference white point. This means that Lab values, while deviceindepdendent, represent the realworld appearance of a colored object viewed under an illuminant with the specified white point. Under illuminant D65, for example (which is the illuminant for sRGB), the normalized white point values are
The script converts Lab values to the sRGB color space via chromatic adaptation from a D50 working space, which is what popular photo editors use.
https://en.wikipedia.org/wiki/Lab_color_space
https://en.wikipedia.org/wiki/White_point
http://www.brucelindbloom.com/index.html?Eqn_ChromAdapt.html
2000pxLab_color_space.svg.png by Jacob Rus
https://commons.wikimedia.org/wiki/File:Lab_color_space.svg
