Convert XYZ to RGB

Hi everybody,

I’ve tried to calculate radiance rgb values from the XYZ values (CIE-XYZ) with xyz_rgb.cal, but the result that I got seems wrong. The exact command I used was:

rcalc -f xyz_rgb.cal -e "$1=R($1,$2,$3);$1=G($1,$2,$3);$1=B($1,$2,$3)" input.txt> output.txt

The input file contains the following:

100
0
0

and the output was:

7.47243773
0
0

. For comparision of the result I used: https://www.jaloxa.eu/resources/radiance/colour_picker.shtml. It would be awesome if somebody could tell me where my mistake is.

Greetings Philip

The Jaloxa colour picker uses the Radiance xyz_rgb.cal set of formulas, and should give the same result as running rcalc -f xyz_rgb.cal. It uses these primaries (again, from Radiance):

var CIE_pri = new Array(0.640,0.330, 0.290,0.600, 0.150,0.060, 0.33333,0.33333);

I noticed a typo in your -e expression. It should be “$1=…;$2=…;$3=…”. You are defining $1 three times.

It might also be a good idea to use physically possible XYZ. (1,0,0) is outside the CIE 1932 horseshoe diagram. I wonder whether this causes some unexpected behaviour. Try this, which gives the same result in the colour picker where you would use (30, 40, 50):

echo .3 .4 .5 | rcalc -f xyz_rgb.cal -e '$1=R($1,$2,$3);$2=G($1,$2,$3);$3=B($1,$2,$3)'
0.103622393     0.506592973     0.510249081

Cheers

Axel

Aaah, also: the input file needs to have 3 columns, not 3 rows!

Thanks @Axel_Jacobs2 for the fast reply and the solution.

Greetings Philip