converting XYZ color to RGB
16,277
There is a simple linear relationship between RGB and XYZ spaces (if you wish you can express this in matrix form in the obvious way):
R = 3.2404542*X - 1.5371385*Y - 0.4985314*Z
G = -0.9692660*X + 1.8760108*Y + 0.0415560*Z
B = 0.0556434*X - 0.2040259*Y + 1.0572252*Z
However, if what you meant is sRGB space, then additional non-linear transformation needs to be applied to each component: R=adj(R)
, G=adj(G)
, and B=adj(B)
. The adj
function is defined as follows:
function adj(C) {
if (Abs(C) < 0.0031308) {
return 12.92 * C;
}
return 1.055 * Math.pow(C, 0.41666) - 0.055;
}
Author by
kamran amingalvani
Updated on June 27, 2022Comments
-
kamran amingalvani almost 2 years
color-primary transformations
Does anyone know of any formula for converting a XYZ to an RGB value?
how find rgb from XYZ in this pic?
-
beaker about 7 yearsI'm sure wikipedia does. What research have you done?
-
Wyzard about 7 yearsThere's no generic "XYZ to RGB" because "RGB" doesn't have a precise meaning. You need to choose a specific color space that has specific primaries, such as sRGB.
-
Manfred Radlwimmer about 7 yearsThere is a lot of math involved. My recommendation would be Bruce Lindbloom's Website. It contains all the formulas, parameters and background knowledge you need to konverta a color from one color space to another.
-
-
Константин Ван over 3 yearsThat matrix is of sRGB, and sRGB is not the only RGB color space.