a742788fc9be87ca21f5f5adbb8098959477c043
[dcpomatic.git] / doc / manual / colour.tex
1 \documentclass{article}
2
3 \pagestyle{empty}
4 \usepackage{amsmath,mathtools}
5 \title{Colour conversion in DCP-o-matic}
6 \author{}
7 \date{}
8 \begin{document}
9 \maketitle
10
11 Conversion from an RGB pixel $(r, g, b)$ is done in three steps.
12 First, the input gamma $\gamma_i$ is applied.  This is done in one of
13 two ways, depending on the setting of the ``linearise input gamma
14 curve for low values'' option.  If linearisation is disabled, we use:
15
16 \begin{align*}
17 r' &= r^{\gamma_i} \\
18 g' &= g^{\gamma_i} \\
19 b' &= b^{\gamma_i}
20 \end{align*}
21
22 otherwise, with linearisation enabled, we use:
23
24 \begin{align*}
25 r' &= \begin{dcases}
26 \frac{r}{12.92} & r \leq 0.04045 \\
27 \left(\frac{r + 0.055}{1.055}\right)^{\gamma_i} & r > 0.04045
28 \end{dcases}
29 \end{align*}
30
31 Next, the colour transformation matrix is used to convert to XYZ:
32
33 \begin{align*}
34 \left[\begin{array}{c}
35 x \\
36 y \\
37 z
38 \end{array}\right] &=
39 \left[\begin{array}{ccc}
40 m_{11} & m_{12} & m_{13} \\
41 m_{21} & m_{22} & m_{23} \\
42 m_{31} & m_{32} & m_{33}
43 \end{array}\right]
44 \left[\begin{array}{c}
45 r' \\
46 g' \\
47 b'
48 \end{array}\right]
49 \end{align*}
50
51 Finally, the output gamma $\gamma_o$ is applied to give our final XYZ values $(x', y', z')$:
52
53 \begin{align*}
54 x' &= x^{1/\gamma_o} \\
55 y' &= y^{1/\gamma_o} \\
56 z' &= z^{1/\gamma_o} \\
57 \end{align*}
58
59 \end{document}