1 color

1.1 complementary colors

Colors that when mixed together produce white. For example, in RGB model the following pairs of colors are complementary:

1.2 color model

1.2.1 RGB

(R, G, B) - three primary colors, Red, Green, Blue added together to produce colors.

1.2.2 CMY

(C, M, Y) - three primary colors, Cyan, Magenta, Yellow subtracted together to produce colors.

\begin{bmatrix} C \\ M \\ Y \\ \end{bmatrix} = \begin{bmatrix} 1 \\ 1 \\ 1 \\ \end{bmatrix} - \begin{bmatrix} R \\ G \\ B \\ \end{bmatrix}

Used in printing, due to reliance on reflecting external light. Even though theory mixing cyan magenta and yellow should produce black, this is often not the case in the real world and thus black is introduced as a separate color.

1.2.3 Y’UV / Y’IQ

Encoding of RGB for analog or digital TV signal transmission

R,G,B,Y' \in [0; 1]

U \in [−0.436; 0.436], V \in [−0.615; 0.615]

\begin{bmatrix} Y' \\ U \\ V \\ \end{bmatrix} = \begin{bmatrix} 0.299 & 0.587 & 0.114 \\ -0.14713 & -0.28886 & 0.436 \\ 0.615 & -0.51499 & -0.10001 \\ \end{bmatrix}\begin{bmatrix} R \\ G \\ B \\ \end{bmatrix}

I \in [−0.596; 0.596], Q \in [−0.523; 0.523]

\begin{bmatrix} Y' \\ I \\ Q \\ \end{bmatrix} = \begin{bmatrix} 0.299 & 0.587 & 0.114 \\ 0.595716 & -0.274453 & -0.321263 \\ 0.211456 & -0.522591 & 0.311135 \end{bmatrix}\begin{bmatrix} R \\ G \\ B \\ \end{bmatrix}

Conversion to grayscale: Y' = 0.299R + 0.587G + 0.114B

1.2.4 HSV / HSL

Hue, saturation, brightness/lightness

M = \max(R,G,B), m = \min(R,G,B), then

H = 60^\circ \cdot \begin{cases} 0 & \text{ if } M = m \\ \frac{G - B}{M - m} \mod 6 & \text{ if } M = R \\ \frac{B - R}{M - m} + 2 & \text{ if } M = G \\ \frac{R - G}{M - m} + 4 & \text{ if } M = B \\ \end{cases}

S_{HSV} = \frac{\max(R, G, B) − \min(R, G, B)}{\max(R, G, B)}

S_{HSL} = \frac{\max(R, G, B) − \min(R, G, B)}{1 - |\max(R, G, B) + \min(R, G, B) - 1|}

V = \max(R, G, B)

L = \frac{\max(R, G, B) + \min(R, G, B)}{2}

1.2.5 absolute color space

Color space where colors are unambiguous. For example RGB can become an absolute color space if we account for individual color profiles of devices.

1.2.5.1 CIE RGB 1931

International Commission on Illumination (CIE) defines standard absolute color spaces such as CIE RGB 1931. Primary colors are a set of monochromatic single wavelength colors:

\begin{aligned} R & = \int_0^\infty I(\lambda)\bar r(\lambda) d\lambda \\ G & = \int_0^\infty I(\lambda)\bar g(\lambda) d\lambda \\ B & = \int_0^\infty I(\lambda)\bar b(\lambda) d\lambda \\ \end{aligned}

Where I(\lambda) is the spectral power distribution.

1.2.5.2 CIE xyY chromaticity diagram

Chromaticity Diagram
1.2.5.2.1 white point

White Point defines a reference white color for image capture or reproduction. It can be specified either by (x, y) coordinates on a chromaticity diagram or by color temperature. Where color temperature is the temperature of a black body which radiation is closest to the spectral power distribution of the surrounding ambient light.

1.3 color quantization

Representing an image with a limited set of colors (color palette)

1.3.1 fixed quantization

Fixed color palette, fixed mapping. Causes color shifts, false contours.

1.3.1.1 uniform

Uniform subdivision of RGB cube for each coordinate, mapping done with some respect to some distance function (for example Euclidean distance).

1.3.2 adaptive quantization

Image-dependent color palette.

1.3.2.1 popularity

We select k most frequent occurring colors.

1.3.2.2 median cut

Subdivide color space such that each cuboid has the same amount of pixels

1.3.2.3 k-means

k-colors as the k-centroids of the color space from k-means algorithm