Various alterations to the manual.
[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 and similarly for $g$ and $b$.
32
33 Next, the colour transformation matrix is used to convert to XYZ:
34
35 \begin{align*}
36 \left[\begin{array}{c}
37 x \\
38 y \\
39 z
40 \end{array}\right] &=
41 \left[\begin{array}{ccc}
42 m_{11} & m_{12} & m_{13} \\
43 m_{21} & m_{22} & m_{23} \\
44 m_{31} & m_{32} & m_{33}
45 \end{array}\right]
46 \left[\begin{array}{c}
47 r' \\
48 g' \\
49 b'
50 \end{array}\right]
51 \end{align*}
52
53 Note: some tools apply a white-point correction here, but DCP-o-matic currently does not do that.
54
55 Finally, the output gamma $\gamma_o$ is applied to give our final XYZ values $(x', y', z')$:
56
57 \begin{align*}
58 x' &= x^{1/\gamma_o} \\
59 y' &= y^{1/\gamma_o} \\
60 z' &= z^{1/\gamma_o} \\
61 \end{align*}
62
63 \end{document}