XYZ to Lab

This conversion requires a reference white $(X_r , Y_r , Z_r)$.

$$L = 116 f_y - 16$$ $$a = 500(f_x - f_y)$$ $$b = 200(f_y - f_z)$$

where

$$f_x = \cases{ \sqrt[3]{x_r} & \text{if }x_r \gt \epsilon \\ {{\kappa x_r + 16} \over {116}} & \text{otherwise} }$$ $$f_y = \cases{ \sqrt[3]{y_r} & \text{if }y_r \gt \epsilon \\ {{\kappa y_r + 16} \over {116}} & \text{otherwise} }$$ $$f_z = \cases{ \sqrt[3]{z_r} & \text{if }z_r \gt \epsilon \\ {{\kappa z_r + 16} \over {116}} & \text{otherwise} }$$ $$x_r = {{X} \over {X_r}}$$ $$y_r = {{Y} \over {Y_r}}$$ $$z_r = {{Z} \over {Z_r}}$$ $$\epsilon = \cases{ {0.008856} & \text{Actual CIE standard} \\ {216 / 24389} & \text{Intent of the CIE standard} }$$ $$\kappa = \cases{ {903.3} & \text{Actual CIE standard} \\ {24389 / 27} & \text{Intent of the CIE standard} }$$

Implementation Notes:

  1. For an explanation of $\epsilon$ and $\kappa$ click here.