1

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?

Snaky
  • 101
  • 1
  • 3
  • 2
    `xy` coordinates represent only the chrominance without the luminance. It is not possible to get XYZ from xy coordinates. Selecting Y = 1 may be useful in some color balancing algorithms. – Rotem Sep 08 '22 at 18:56
  • 1
    Or better: set Y as the Y value for white, or the highest possibly value for such xy hue. xy is chromacity (so see it as *hue*), and so often it is set at maximum luminosity – Giacomo Catenazzi Sep 12 '22 at 07:20

0 Answers0