Back to Articles

2026-09-27

From LMS to OkLab

By Anthony Dito

Learn how LMS cone responses are converted into OkLab lightness and opponent color axes with a signed cube root and a matrix transformation.

OkLab is a perceptual color space: its three components describe the lightness and color relationships we see, rather than the red, green, and blue light emitted by a display. To arrive at those components, we start with LMS values, which model the responses of the eye's long-, medium-, and short-wavelength cone cells.

Converting LMS to OkLab

Given LMS values l, m, and s, the conversion to OkLab is:

Matrix formula that converts signed cube roots of LMS values l, m, and s into OkLab L, a, and b values

Here, the signed cube root preserves the sign of its input: cbrt(x) = sign(x) · abs(x)1 / 3. This makes the transformation continue to work for values below zero.

Reading the Matrix

Matrices appear again here, but you do not need to multiply one by hand to see what this one does. Each row describes one OkLab component. The L row has positive values in the l and m columns, meaning that lightness is built from the long- and medium-wavelength responses in those proportions.

The a row has a strong positive value for the long-wavelength response and a strong negative value for the medium-wavelength response. The difference between those responses controls the red-green axis. The b row has a strong positive value for the medium-wavelength response and a strong negative value for the short-wavelength response, so their difference controls the yellow-blue axis.

The cube root makes the relationship between wavelength responses and perceived color nonlinear. It is one of the steps that lets equal numerical changes in OkLab better correspond to equal-looking changes in color.

If you would like a refresher on the matrix operations behind the formula, read Why Matrix Composition Works.

Try It in BrushCue

BrushCue's Chroma Offset tool works along the OkLab color axes, making it useful for perceptual color adjustments that preserve lightness.