メインコンテンツまでスキップ

xyz2lab: CIE XYZ to LAB Color Space Conversion

Perceptually Uniform Color Representation

The xyz2lab function transforms CIE XYZ coordinates into the LAB color space, where equal distances correspond to equal perceived color differences. This transformation applies the CIE LAB formula with D65 illuminant normalization.

Mathematical Foundation

The conversion applies three stages of transformation. First, values are normalized by the D65 white point:

n=XYZXYZwhite=XYZ[95.047,100.0,108.883]n = \frac{XYZ}{XYZ_{white}} = \frac{XYZ}{[95.047, 100.0, 108.883]}

Then the cube root function or linear approximation is applied:

f(t)={t3if t>δt7.787+16/1161otherwisef(t) = \begin{cases} \sqrt[3]{t} & \text{if } t > \delta \\ \frac{t \cdot 7.787 + 16/116}{1} & \text{otherwise} \end{cases}

Finally, LAB coordinates are computed:

L=116f(Y)16a=500(f(X)f(Y))b=200(f(Y)f(Z))\begin{align} L^* &= 116f(Y) - 16 \\ a^* &= 500(f(X) - f(Y)) \\ b^* &= 200(f(Y) - f(Z)) \end{align}

LAB Components Visualization

ライブエディター
const fragment = () => {
      const X = uv.x.mul(100)
      const Y = uv.y.mul(100)
      const Z = float(50)
      const xyzColor = vec3(X, Y, Z)
      const labColor = xyz2lab(xyzColor)
      return vec4(labColor.normalize(), 1)
}