Color conversion, get XYZ from xy coordinates

Viewed 20

I am getting x/y coordinates from a GUI which need to be converted to sRGB. Y is missing, just a "Brightness" is available also. Since "Brightness" and Y are two totally different things I try to go with x/y.

Converting to X/Y/Z we can use for the whitepoint coordinates a Y value of 1

local function xytoXYZ(x, y)
    if y == 0 then
        return 0, 0, 0
    end
    local z = 1.0 - x - y
    local Y = 1
    local X = (Y / y) * x
    local Z = (Y / y) * z
    return X, Y, Z
end

The resulting X/Y/Z can be converted to sRGB color spaces with acceptable results.

But how to get X/Y/Z for all other x/y coordinates which are NOT the whitepoint?

0 Answers
Related