ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/cal/cal/vonKries.cal
Revision: 1.2
Committed: Wed Nov 21 18:10:45 2018 UTC (5 years, 6 months ago) by greg
Branch: MAIN
CVS Tags: rad5R4, rad5R3, HEAD
Changes since 1.1: +1 -0 lines
Log Message:
Added missing RCSid tag

File Contents

# User Rev Content
1 greg 1.2 { RCSid $Id$ }
2 greg 1.1 {
3     von Kries white point transformation
4    
5     Input:
6     w0x, w0y - original white point chromaticity coords.
7     w1x, w1y - destination white point chromaticities
8     Output:
9     C00 to C22 - XYZ conversion matrix
10     }
11    
12     MatDot(A,B,i,j) : A(i,0)*B(0,j) + A(i,1)*B(1,j) + A(i,2)*B(2,j);
13    
14     i3(i) : if(i-2.5, i-3, i);
15    
16     MinorDet(M,i,j) : M(i3(i+1),i3(j+1))*M(i3(i+2),i3(j+2)) -
17     M(i3(i+1),i3(j+2))*M(i3(i+2),i3(j+1));
18    
19     Det(M) : M(0,0)*MinorDet(M,0,0) +
20     M(0,1)*MinorDet(M,0,1) +
21     M(0,2)*MinorDet(M,0,2);
22    
23     Inv(M,i,j) : MinorDet(M,j,i) / Det(M);
24    
25     { Original matrix from p. 480 of "Digital Color Management" }
26     {
27     vKmat(i,j) : select(i*3+j+1, .40024, .70760, -.08081,
28     -.22630,1.16532,.04570,
29     0, 0, .91822 );
30     }
31     { Primary conversion matrix copied from Susstrunk's paper (CMCCAT2000) }
32     {
33     vKmat(i,j) : select(i*3+j+1, .7982, .3389, -.1371,
34     -.5918, 1.5512, .0406,
35     .0008, .0239, .9753 );
36     }
37     { Sharp conversion matrix (also from Susstrunk paper) }
38     vKmat(i,j) : select(i*3+j+1, 1.2694, -.0988, -.1706,
39     -.8364, 1.8006, .0357,
40     .0297, -.0315, 1.0018 );
41    
42     ivKmat(i,j) : Inv(vKmat,i,j);
43    
44     X0 = w0x/w0y;
45     Y0 = 1;
46     Z0 = (1-w0x-w0y)/w0y;
47    
48     X1 = w1x/w1y;
49     Y1 = 1;
50     Z1 = (1-w1x-w1y)/w1y;
51    
52     rho0 = vKmat(0,0)*X0 + vKmat(0,1)*Y0 + vKmat(0,2)*Z0;
53     gam0 = vKmat(1,0)*X0 + vKmat(1,1)*Y0 + vKmat(1,2)*Z0;
54     bet0 = vKmat(2,0)*X0 + vKmat(2,1)*Y0 + vKmat(2,2)*Z0;
55    
56     rho1 = vKmat(0,0)*X1 + vKmat(0,1)*Y1 + vKmat(0,2)*Z1;
57     gam1 = vKmat(1,0)*X1 + vKmat(1,1)*Y1 + vKmat(1,2)*Z1;
58     bet1 = vKmat(2,0)*X1 + vKmat(2,1)*Y1 + vKmat(2,2)*Z1;
59    
60     shiftMat(i,j) = select(i*3+j+1, rho1/rho0, 0, 0,
61     0, gam1/gam0, 0,
62     0, 0, bet1/bet0 );
63    
64     M1(i,j) = MatDot(ivKmat,shiftMat,i,j);
65     C(i,j) = MatDot(M1,vKmat,i,j);
66    
67     { Defined as constants so one evaluation only }
68     C00 : C(0,0); C01 : C(0,1); C02 : C(0,2);
69     C10 : C(1,0); C11 : C(1,1); C12 : C(1,2);
70     C20 : C(2,0); C21 : C(2,1); C22 : C(2,2);
71    
72     { Extra goodies... }
73    
74     XYZ2VYU(j,i) : select(i*3+j+1, 1.362,0,.033,-1.093,1,-.631,-.205,0,.507);