Skip to main content

XYZ and CIE L*a*b*

Tristimulous Values ⇄ Perceptual Lightness, Red/Green Variance, Blue/Yellow Variance

W is a 1x3 reference white vector of a standard illuminant. The κ and ϵ constants are given by CIE standards used to calculate values above or below the junction point of the companding functions below. Before 2004, approximations were used such that κ = 903.3 and ϵ = 0.008856.

ϵ=241163κ=116123\begin{align*} \epsilon &= \frac{24}{116}^3 \\ \kappa &= \frac{116}{12}^3 \end{align*}

XYZ to L*a*b*

X=XWXY=YWYZ=ZWZf(n)={n13 if n>ϵκn+16116 otherwise L=116f(Y)16a=500(f(X)f(Y))b=200(f(Y)f(Z))L=min(max(L,0)1)\begin{align*} X' &= \frac{X}{W_X} \\ Y' &= \frac{Y}{W_Y} \\ Z' &= \frac{Z}{W_Z} \\ \:\\ f(n) &= \begin{cases} n'^\frac{1}{3} & \text{ if } n > \epsilon \\ \frac{\kappa \cdot n' + 16}{116} & \text{ otherwise } \end{cases} \\ \:\\ L^* &= 116 \cdot f(Y) - 16 \\ a^* &= 500 \cdot (f(X) - f(Y)) \\ b^* &= 200 \cdot (f(Y) - f(Z)) \\ \:\\ L^* &= min(max(L^*,0)1) \end{align*}

L*a*b* to XYZ

L=L+16116a=a500+Lb=Lb200X={a3 if a3>ϵ116a16κ otherwise Y={L3 if L>κϵLκ otherwise Z={b3 if b3>ϵ116b16κ otherwise X=XWXY=YWYZ=ZWZ\begin{align*} L' &= \frac{L^* + 16}{116} \\ a' &= \frac{a^*}{500} + L' \\ b' &= L' - \frac{b^*}{200} \\ \:\\ X' &= \begin{cases} a'^3 & \text{ if } a'^3 > \epsilon \\ \frac{116 \cdot a' - 16}{\kappa} & \text{ otherwise } \end{cases}\\ Y' &= \begin{cases} L'^3 & \text{ if } L^* > \kappa \cdot \epsilon \\ L^* \cdot \kappa & \text{ otherwise } \end{cases}\\ Z' &= \begin{cases} b'^3 & \text{ if } b'^3 > \epsilon \\ \frac{116 \cdot b' - 16}{\kappa} & \text{ otherwise } \end{cases} \\ \:\\ X &= X' \cdot W_X \\ Y &= Y' \cdot W_Y \\ Z &= Z' \cdot W_Z \end{align*}