Colour conversions for DCP creation
Carl Hetherington, Dennis Couzin
1     Overview
The process of conversion from RGB to XYZ is:
    1. Convert to linear RGB (i.e. apply a gamma curve, or at least an approximation to one).
    2. Convert to XYZ (preserving the white point).
    3. Adjust the white point.
    4. Normalize values.
    5. Convert to non-linear XYZ (i.e. apply a gamma curve)
2     Convert to linear RGB
This is done using either a ‘pure’ gamma function, so that for some colour value Ci the output colour Co is given by
                                                             Co = Ciγ                                                  (1)
    or a modified function of the form
                                                            Ci
                                                                          Ci ≤ Ct
                                                        (
                                                 Co =       K       ζ                                                (2)
                                                             Ci +A
                                                             1+A          Ci > Ct
    where K, A, Ct and ζ are constants. This modified function approximates a ‘pure’ gamma function but changes the output
for small inputs.
                                                                 1
3     Convert to XYZ
This is done by multiplying the colours by a 3 × 3 matrix. This matrix depends on the chromaticities of the RGB primaries and
the white point. Note that these are the same for BT709 and sRGB, so the corresponding matrices are the same.
   The chromaticities for sRGB and BT709 are shown in Table ??. The white point is (x = 0.3127, y = 0.329); this is called
D65.
                                                             x       y
                                                    Red      0.64    0.33
                                                    Green    0.3     0.6
                                                    Blue     0.15    0.06
                                      Table 1: RGB chromaticities for sRGB and BT709
    Let
                                                       Rx − Wx      Wx − Bx
                                                 D=                                                                       (3)
                                                       Ry − Wy      Wy − By
                                                       Wx − Gx      Rx − Wx
                                                 E=                                                                       (4)
                                                       Wy − Gy      Ry − Wy
                                                     Wx − Gx Wx − Bx
                                                 F =                                                                      (5)
                                                     Wy − Gy Wy − By
                                                            D     E
                                                 P = Ry + Gy + By                                                         (6)
                                                            F     F
    where:
    • Rx , Ry : red point; Rz = 1 − Rx − Ry
    • Gx , Gy : green point; Gz = 1 − Gx − Gy
    • Bx , By : blue point; Bz = 1 − Bx − By
    • Wx , Wy : white point
                                                             2
       Then the conversion matrix C is as follows:
                                                          
                                                 D       E
                                     Rx      Gx
                                                 F
                                                      Bx 
                                                         F                                 
                                                                0.4123908 0.3575843 0.1804808
                                     
                                   1            D       E
                                C =  Ry      Gy      By    = 0.2126390 0.7151687 0.0721923                              (7)
                                     
                                   P            F       F
                                                                0.0193308 0.1191948 0.9505322
                                                           
                                                D       E
                                       Rz     Gz      Bz
                                                          
                                                 F       F
       Then to convert RGB to XYZ we do
                                                  
                                          X         R
                                          Y  = C G                                                                      (8)
                                           Z        B
i.e.
                                                                              
                                          X       0.4123908 0.3575843 0.1804808   R
                                          Y  = 0.2126390 0.7151687 0.0721923 G                                        (9)
                                           Z      0.0193308 0.1191948 0.9505322   B
       Note: there is also a CIE definition of the D65 white point as (x = 0.31272, y = 0.32903), which we do not use.
4        Adjust the white point
If required we can adjust the white point of the colours from one white point S1 to another S2 . This is done by multiplication
by a Bradford matrix, B. To calculate it, we start with the Bradford chromatic adaption transform matrix M, taken from
Süsstrunk et al., Chromatic adaption performance of different RGB sensors, IS&T/SPIE Electronic Imaging, SPIE Vol. 4300
(2001).
                                                                                   
                                                     0.8951       0.2664    −0.1614
                                                M = −0.7502      1.7135     0.0367                                      (10)
                                                     0.0389      −0.0685     1.0296
                                                                  3
    The inverse of M is
                                                                                          
                                           0.9869929055       −0.1470542564   0.1599626517
                                 M−1   =  0.4323052697        0.5183602715   0.0492912282    (11)
                                          −0.0085286646        0.0400428217   0.9684866958
    Next, compute G and H as follows
                                                            S1x      
                                                            S1y      
                                                                     
                                                 G = M       1                               (12)
                                                       1 − S1x − S1y 
                                                                     
                                                             S1y
                                                            S      2x
                                                                      
                                                            S2y      
                                                                     
                                                 H = M       1                               (13)
                                                       1 − S2x − S2y 
                                                                     
                                                             S2y
    Then the Bradford matrix B is given by
                                                        H1
                                                                           
                                                      G1         0     0  
                                                                 H2        
                                             B = M−1  0                0  M                (14)
                                                                           
                                                                 G2        
                                                                       H3  
                                                        0          0
                                                                         G3
                                                                                               (15)
5     Normalize values
Here we just multiply all colour values by the constant N where
                                                                 48
                                                        N=                                     (16)
                                                                52.37
                                                               4
6    Convert to non-linear XYZ
This is a gamma correction of 1/2.6, so that for some colour value Ci the output colour Co is given by
                                                                  1/2.6
                                                          Co = Ci                                        (17)
7    Converting from a colour matrix to chromaticities
To get back from a colour matrix C to the chromaticities:
                                              C11
                                 Rx =                                                                    (18)
                                        C11 + C21 + C31
                                              C21
                                 Ry =                                                                    (19)
                                        C11 + C21 + C31
                                              C12
                                 Gx =                                                                    (20)
                                        C12 + C22 + C32
                                              C22
                                 Gy =                                                                    (21)
                                        C12 + C22 + C32
                                              C13
                                 Bx =                                                                    (22)
                                        C13 + C23 + C33
                                              C23
                                 By =                                                                    (23)
                                        C13 + C23 + C33
                                                       C11 + C12 + C13
                                Wx =                                                                     (24)
                                     C11 + C12 + C13 + C21 + C22 + C23 + C31 + C32 + C33
                                                       C21 + C22 + C23
                                Wy =                                                                     (25)
                                     C11 + C12 + C13 + C21 + C22 + C23 + C31 + C32 + C33