How to Convert LCH to OKLab
Converting LCH to OKLab is an upgrade from a 1970s perceptual color model to a modern, highly optimized one. While LCH is excellent, it is based on the older CIELAB math, which has known flaws.
Why Upgrade to OKLab?
The most prominent flaw in CIELAB (and by extension, LCH) is the "blue shift." When transitioning from blue to white, 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 LCH coordinates directly to OKLab coordinates. The color must be translated back into a linear light space first.
- Convert LCH to CIELAB using trigonometry.
- Convert CIELAB to the CIE XYZ reference space.
- 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.