# CIE Color Conversion

Hi All

I have a question about using the existing utilities for converting a CIE (x,y) chromaticity to RGB for use of adjusting the default sun and sky colors. I have researched the following site to get some background about this:

From searching through the archive of this message board I came across a

response by Greg to a previous question that I had for adjusting the sun color:

My question is how may I convert from a CIE(x,y) chromaticity to RGB using on two variables as was performed for the above. The Radiance function file xyz_rgb.cal requires three variables (x,y and the luminosity, z). The reason why I am asking this is because I wish for the values that I'll employ to be in the physically valid range (i.e. .265074126*r + .670114631*g + .064811243*b = 1).

Thanks

Marcus

Hi Marcus,

To get RGB values from CIE Yxy input, you need an additional conversion from Yxy to XYZ, i.e.:

X = Y*x/y;
{ Y = Y; }
Z = Y*(1 - x - y)/y;

This can go inline with xyz_rgb.cal like so:

rcalc -e 'Y_i=\$1;x_i=\$2;y_i=\$3' -e 'X_i=Y_i*x_i/y_i;Z_i=Y_i*(1-x_i-y_i)/y_i' -f xyz_rgb.cal

If you give Y x y on input, you'll get RGB on output. (You can use a Y of 1 if you like.)

-Greg

···

From: "Marcus Jacobs" <[email protected]>
Date: June 23, 2005 8:20:24 PM BDT

Hi All

I have a question about using the existing utilities for converting a CIE (x,y) chromaticity to RGB for use of adjusting the default sun and sky colors. I have researched the following site to get some background about this:

Colour Rendering of Spectra

From searching through the archive of this message board I came across a
response by Greg to a previous question that I had for adjusting the sun color:

My question is how may I convert from a CIE(x,y) chromaticity to RGB using on two variables as was performed for the above. The Radiance function file xyz_rgb.cal requires three variables (x,y and the luminosity, z). The reason why I am asking this is because I wish for the values that I'll employ to be in the physically valid range (i.e. .265074126*r + .670114631*g + .064811243*b = 1).

Thanks

Marcus

Hi Marcs,

These are the formulas you need to convert from Yxy to radiance-rgb:

X=x*Y/y;
Z=(1-x-y)*Y/y;
r= 2.565*X -1.167*Y -0.398*Z;
g= -1.022*X +1.978*Y +0.044*Z;
b= 0.075*X -0.252*Y +1.177*Z;

Raphael

···

At 23.06.2005 21:20, you wrote:

Hi All

I have a question about using the existing utilities for converting a CIE (x,y) chromaticity to RGB for use of adjusting the default sun and sky colors. I have researched the following site to get some background about this:

Colour Rendering of Spectra

From searching through the archive of this message board I came across a response by Greg to a previous question that I had for adjusting the sun color: