How to Convert CIELAB to OKLab
Converting CIELAB (Lab) to OKLab is an upgrade from a 1970s perceptual color model to a modern, highly optimized one. Both spaces use the same L, a, and b axes, but OKLab calculates them using better math.
Why Upgrade to OKLab?
CIELAB was a massive achievement when it was introduced in 1976, but it has known flaws. The most prominent is the "blue shift." When transitioning from blue to white in CIELAB, the color shifts toward purple. It also struggles to maintain consistent perceived saturation across different hues.
OKLab was created in 2020 to fix these specific issues. It uses LMS (Long, Medium, Short) cone responses to better simulate how the human eye processes light. Gradients and color mixing done in OKLab are smooth, hue-stable, and free of the purple shift.
The Conversion Pipeline
You cannot map CIELAB coordinates directly to OKLab coordinates. The color must be translated back into a linear light space first.
- Convert CIELAB to the CIE XYZ reference space (using a D50 white point).
- Convert XYZ to Linear sRGB.
- Multiply the Linear sRGB values by the OKLab transformation matrix to enter LMS cone space.
- Apply the OKLab non-linear curve and final matrix to get the new
L,a, andbvalues.