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