Convert XYZ to RGB

Hi everybody,

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

rcalc -f -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:


and the output was:


. For comparision of the result I used: It would be awesome if somebody could tell me where my mistake is.

Greetings Philip

The Jaloxa colour picker uses the Radiance set of formulas, and should give the same result as running rcalc -f 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 -e '$1=R($1,$2,$3);$2=G($1,$2,$3);$3=B($1,$2,$3)'
0.103622393     0.506592973     0.510249081



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