lab2rgb: CIELAB to RGB Color Space Conversion
Perceptually Uniform Color Space Transformation
The lab2rgb
function converts colors from the CIELAB color space to RGB, utilizing the perceptually uniform properties of LAB space for advanced color manipulations. CIELAB is designed to approximate human vision, where equal distances in color space correspond to equal perceived color differences.
Mathematical Foundation
The conversion follows a two-step process through CIE XYZ intermediate space:
The LAB to XYZ transformation applies the inverse of the CIE LAB formula:
where , , and .
The XYZ to RGB conversion uses the standard sRGB color matrix:
LAB Color Space Exploration
Live Editor
const fragment = () => { const center = vec2(0.5) const p = uv.sub(center).mul(1000) const L = uv.y const A = p.x const B = p.y const labColor = vec3(L, A, B) const rgbColor = lab2rgb(labColor) return vec4(rgbColor.max(0).min(1), 1) }