Color management is based on XYZ tristimulus values. X, Y, and Z are mathematical pseudocolors analogous to the three types of cone cells of the human eye, which are sensitive to long, middle, and short wavelengths. One way to think of X, Y, and Z is “sort of like red,” “sort of like green,” and “sort of like blue.” Three parameters like this can in principle describe any color sensation. The colormatching functions that define the response of the X, Y, and Z “receptors” are known as the CIE standard observer.
The CIE XYZ color space is deviceindependent, and encompasses all color sensations that an average person can experience. But not all XYZ combinations correspond to real colors that can be physically produced by spectral distributions of light.
Tristimulus values are converted to real RGB colors via a 3×3 matrix and gamma correction, or a lookup table (LUT) in the case of complex color profiles. The white point of the RGB color space is implicit in the transformation. This script converts XYZ values to the sRGB color space, which web browsers use by specification. Outofgamut colors are noted. Larger color spaces would have larger gamuts; the accuracy of their representation would depend on the gamut of the display device used to view them. The matrix and gamma function for sRGB:
where a = 0.055
https://en.wikipedia.org/wiki/CIE_1931_color_space
https://en.wikipedia.org/wiki/SRGB
http://www.cvrl.org/ciexyzpr.htm
287pxCones_SMJ2_E.svg.png by Vanessaezekowitz at en.wikipedia, CC BYSA 3.0,
https://commons.wikimedia.org/w/index.php?curid=10514373
325pxCIE_1931_XYZ_Color_Matching_Functions.svg.png by User:Acdx  Own work, GFDL,
https://commons.wikimedia.org/w/index.php?curid=6233111
