summaryrefslogtreecommitdiff
path: root/doc/manual/colour.tex
blob: 8550034a839ba97af6ce3f053ebeecf931e18256 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
\documentclass{article}

\pagestyle{empty}
\usepackage{amsmath,mathtools}
\title{Colour conversion in DCP-o-matic}
\author{}
\date{}
\begin{document}
\maketitle

Conversion from an RGB pixel $(r, g, b)$ is done in three steps.
First, the input gamma $\gamma_i$ is applied.  This is done in one of
two ways, depending on the setting of the ``linearise input gamma
curve for low values'' option.  If linearisation is disabled, we use:

\begin{align*}
r' &= r^{\gamma_i} \\
g' &= g^{\gamma_i} \\
b' &= b^{\gamma_i}
\end{align*}

otherwise, with linearisation enabled, we use:

\begin{align*}
r' &= \begin{dcases}
\frac{r}{12.92} & r \leq 0.04045 \\
\left(\frac{r + 0.055}{1.055}\right)^{\gamma_i} & r > 0.04045
\end{dcases}
\end{align*}

and similarly for $g$ and $b$.

Next, the colour transformation matrix is used to convert to XYZ:

\begin{align*}
\left[\begin{array}{c}
x \\
y \\
z
\end{array}\right] &=
\left[\begin{array}{ccc}
m_{11} & m_{12} & m_{13} \\
m_{21} & m_{22} & m_{23} \\
m_{31} & m_{32} & m_{33}
\end{array}\right]
\left[\begin{array}{c}
r' \\
g' \\
b'
\end{array}\right]
\end{align*}

Note: some tools apply a white-point correction here, but DCP-o-matic currently does not do that.

Finally, the output gamma $\gamma_o$ is applied to give our final XYZ values $(x', y', z')$:

\begin{align*}
x' &= x^{1/\gamma_o} \\
y' &= y^{1/\gamma_o} \\
z' &= z^{1/\gamma_o} \\
\end{align*}

\end{document}