Color conversion, get XYZ from xy coordinates

458 Views Asked by At

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?

1

There are 1 best solutions below

0
Myndex On

Short Answer:

You need to convert the "brightness" you menioned you have to Y.

Longer Answer

The xy coordinates on the chromaticity diagram do not define the color, and the Y value is needed and not optional. While the 1931 chromaticity diagram may appear as if a 2D surface, it is not, and without the third dimension of Y, you have an incomplete definition of the color.

Brightness

If you are getting a "lightness" or a "brightness" from the API/GUI whatever, it should be convertible to at least a relative luminance Y.

Can you give me a complete description of the value, and how it is presented to you or in the API?