Note: This site is currently "Under construction". I'm migrating to a new version of my site building software. Lots of things are in a state of disrepair as a result (for example, footnote links aren't working). It's all part of the process of building in public. Most things should still be readable though.

RBG Conversions

Code

//Reference-X, Y and Z refer to specific illuminants and observers.
//Common reference values are available on another page. 
//TODO: link the page

var_Y = ( CIE-L* + 16 ) / 116
var_X = CIE-a* / 500 + var_Y
var_Z = var_Y - CIE-b* / 200

if ( var_Y^3  > 0.008856 ) var_Y = var_Y^3
else                       var_Y = ( var_Y - 16 / 116 ) / 7.787
if ( var_X^3  > 0.008856 ) var_X = var_X^3
else                       var_X = ( var_X - 16 / 116 ) / 7.787
if ( var_Z^3  > 0.008856 ) var_Z = var_Z^3
else                       var_Z = ( var_Z - 16 / 116 ) / 7.787

X = var_X * Reference-X
Y = var_Y * Reference-Y
Z = var_Z * Reference-Z

via: