ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/ccolor.c
(Generate patch)

Comparing ray/src/common/ccolor.c (file contents):
Revision 3.3 by greg, Thu May 17 17:10:23 2012 UTC vs.
Revision 3.4 by greg, Fri May 18 20:43:13 2012 UTC

# Line 9 | Line 9 | static const char RCSid[] = "$Id$";
9   #include <math.h>
10   #include "ccolor.h"
11  
12 +                                        /* Sharp primary matrix */
13 + float   XYZtoSharp[3][3] = {
14 +        { 1.2694, -0.0988, -0.1706},
15 +        {-0.8364,  1.8006,  0.0357},
16 +        { 0.0297, -0.0315,  1.0018}
17 + };
18 +                                        /* inverse Sharp primary matrix */
19 + float   XYZfromSharp[3][3] = {
20 +        { 0.8156,  0.0472,  0.1372},
21 +        { 0.3791,  0.5769,  0.0440},
22 +        {-0.0123,  0.0167,  0.9955}
23 + };
24  
25   C_COLOR         c_dfcolor = C_DEFCOLOR;
26  
# Line 57 | Line 69 | static const C_COLOR   cie_zp = { 1, NULL, C_CDSPEC|C_CS
69                          36057L, .0, .0,
70                          };
71  
60                                        /* Sharp primary matrix */
61 static const float      toSharp[3][3] = {
62        { 1.2694, -0.0988, -0.1706},
63        {-0.8364,  1.8006,  0.0357},
64        { 0.0297, -0.0315,  1.0018}
65 };
66                                        /* inverse Sharp primary matrix */
67 static const float      fromSharp[3][3] = {
68        { 0.8156,  0.0472,  0.1372},
69        { 0.3791,  0.5769,  0.0440},
70        {-0.0123,  0.0167,  0.9955}
71 };
72  
73 < static void
73 > /* convert to sharpened RGB color for low-error operations */
74 > void
75   c_toSharpRGB(C_COLOR *cin, double cieY, float cout[3])
76   {
77          double  xyz[3];
# Line 81 | Line 82 | c_toSharpRGB(C_COLOR *cin, double cieY, float cout[3])
82          xyz[1] = cieY;
83          xyz[2] = (1. - cin->cx - cin->cy)/cin->cy * cieY;
84  
85 <        cout[0] = toSharp[0][0]*xyz[0] + toSharp[0][1]*xyz[1] +
86 <                                toSharp[0][2]*xyz[2];
87 <        cout[1] = toSharp[1][0]*xyz[0] + toSharp[1][1]*xyz[1] +
88 <                                toSharp[1][2]*xyz[2];
89 <        cout[2] = toSharp[2][0]*xyz[0] + toSharp[2][1]*xyz[1] +
90 <                                toSharp[2][2]*xyz[2];
85 >        cout[0] = XYZtoSharp[0][0]*xyz[0] + XYZtoSharp[0][1]*xyz[1] +
86 >                                XYZtoSharp[0][2]*xyz[2];
87 >        cout[1] = XYZtoSharp[1][0]*xyz[0] + XYZtoSharp[1][1]*xyz[1] +
88 >                                XYZtoSharp[1][2]*xyz[2];
89 >        cout[2] = XYZtoSharp[2][0]*xyz[0] + XYZtoSharp[2][1]*xyz[1] +
90 >                                XYZtoSharp[2][2]*xyz[2];
91   }
92  
93 < static double
93 > /* convert back from sharpened RGB color */
94 > double
95   c_fromSharpRGB(float cin[3], C_COLOR *cout)
96   {
97          double  xyz[3], sf;
98  
99 <        xyz[0] = fromSharp[0][0]*cin[0] + fromSharp[0][1]*cin[1] +
100 <                                fromSharp[0][2]*cin[2];
101 <        xyz[1] = fromSharp[1][0]*cin[0] + fromSharp[1][1]*cin[1] +
102 <                                fromSharp[1][2]*cin[2];
103 <        xyz[2] = fromSharp[2][0]*cin[0] + fromSharp[2][1]*cin[1] +
104 <                                fromSharp[2][2]*cin[2];
99 >        xyz[0] = XYZfromSharp[0][0]*cin[0] + XYZfromSharp[0][1]*cin[1] +
100 >                                XYZfromSharp[0][2]*cin[2];
101 >        xyz[1] = XYZfromSharp[1][0]*cin[0] + XYZfromSharp[1][1]*cin[1] +
102 >                                XYZfromSharp[1][2]*cin[2];
103 >        xyz[2] = XYZfromSharp[2][0]*cin[0] + XYZfromSharp[2][1]*cin[1] +
104 >                                XYZfromSharp[2][2]*cin[2];
105                                  
106          sf = 1./(xyz[0] + xyz[1] + xyz[2]);
107  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines