Color
Index
Introduction
Colorimetry is the science that quantifies and describes physically the human color perception and color theory, in visual arts, is a body of practical guidance to color mixing.
During the 20th century two important color systems were created. The Munsell Color System and the Natural Color System (NCS). Both were based on human perception and derived from experiments.
Color Space
A color space is the set of colors and luminance values which can be captured, stored or displayed in a medium.
CIE
The CIE 1931 color spaces are the first defined quantitative links between distributions of wavelengths in the electromagnetic visible spectrum, and physiologically perceived colors in human color vision. They were created by the International Commission on Illumination (CIE) in 1931 from a series of experiments that were combined into the specification of the CIE RGB
color space, from which the CIE XYZ
color space was derived.
CIE Chromaticity Diagram
- The diagram represents the colors visible to the average human eye.
- The edge is called spectral locus, the set of spectral colors, pure monochromatic light measured by wavelength in nanometers.
- Most saturated colors are at the edge.
- Least saturated colors are at the center.
- Colors along any line between 2 points can be made by mixing the colors at the end points.
- Line of purples are fully saturated colors that can only be made by mixing red and blue.
The diagram gives a common frame to define color spaces in xyY
coordinates where xy
is chrominance
and Y
is luminance
.
Each color space has a gamut, a subset of colors that can be represented, and is defined by:
- Primary colors (R,G,B).
- White point. Color spaces use illuminants to define reference whites, each illuminant has a correlated color temperature (CCT). The commonly used standard illuminant is D65 at 6504 K.
- Transfer function. Gamma correction is a non-linear operation used to encode and decode luminance or tristimulus values. It is used to take advantage of the non-linear manner in which humans perceive light and color.
Color Spaces
Color space conversion is done with lineal values
and depends on the primary colors
and white points
. There are several lists of matrices to convert RGB/XYZ and XYZ/RGB.
RGB(709)/RGB(2020)
XYZ = RGB709_TO_XYZ_MAT * RGB(709) RGB(2020) = XYZ_TO_RGB2020_MAT * XYZ
Conversion assuming same white points.
XYZ(D50)/XYZ(D65)
LMS(D50) = XYZ_TO_LMS_MAT * XYZ(D50) LMS(D65) = D50_TO_D65_CAT * LMS(D50) XYZ(D65) = LMS_TO_XYZ_MAT * LMS(D65)
White points conversion matrices are called Chromatic Adaptation Transform (CAT) and are equivalent to apply a white balance.
XYZ/xyY
x = X / (X + Y + Z) y = Y / (X + Y + Z) Y = Y
For black, X=Y=Z=0
, set x
and y
to the chromaticity coordinates of the reference white.
ACES
Academy Color Encoding System ACES is a color image encoding system created by industry professionals of Academy of Motion Picture Arts and Sciences.
ACES Pipeline
- IDT: Input Device Transform.
- ACES Color Space.
- LMT: Look Modification Transform (optional).
- RRT: Reference Rendering Transform (tone mapping for a Reference Display Device).
- ODT: Output Device Transform.
ACES has several color spaces, defined by:
- Primary
AP0 = R(0.7347,0.2653) G(0,1) B(0.0001,-0.0770)
. - Primary
AP1 = R(0.713,0.293) G(0.165,0.830) B(0.128,0.044)
. - Reference illuminant
(0.32168,0.33767)
, close to CIE D60.
ACES Color Spaces
ACES working
color spaces are:
- ACEScc: Color grading (AP1 / log).
- ACEScct: Color grading (AP1 / log+toe).
- ACEScg: VFX and composition (AP1 / lineal).
- ACESproxy: Interchange (AP0).
Color Model
A color model is a method to represent colors, typically as tuples of three or four values or components. An image can be represented in memory (with a stride) component-wise or planar-wise.
- Packed formats are represented in memory:
[X1Y1Z1...XnYnZn]
- Planar formats are represented in memory:
[X1...Xn] [Y1...Yn] [Z1...Zn]
- Semi-Planar formats are represented in memory:
[X1...Xn] [Y1Z1...YnZn]
- Interleaved formats are represented in memory following a sampling system, expressed as a three part ratio
J:a:b
. For example4:2:2
has theY
andZ
planes subsampled, they have less information than theX
plane.
[X1Y1X2Z1 X3Y2X4Z2...Xn-1YmXnZm]
RGB
RGB is an additive color model with a separation of red
, green
and blue
additive primary colors.
Additive Color Mixing
When the red, green and blue components have the same range of values the geometric representation has the shape of a cube otherwise it has the shape of a rectangular prism or cuboid.
RGB Color Range
There are multitude RGB pixel formats, the most common formats are:
- RGB888 or RGB24, uses 24 bits (8 bits per component).
- RGB565, uses 16 bits (5 bits R, 6 bits G and 5 bits B).
RGB888/RGB555
short pixel = ((R >> 3) << 11) | ((G >> 2) << 5) | (B >> 3)
CMY
CMY is a subtractive color model with a separation of cyan
, magenta
and yellow
subtractive primary colors.
Subtractive Color Mixing
HSL/HSV
HSL is a color model with hue
, saturation
and level
components.
HSL Color Range
HSV is a color model with hue
, saturation
and value
components (also known as HSB, hue
, saturation
and brightness
).
HSV Color Range
Both color ranges shapes are cylindrical.
- Hue, the angular dimension, starts at the red primary at 0°, passes through the green primary at 120° and the blue primary at 240°, and then back to red at 360°.
- The central vertical axis is the achromatic grayscale range, from top to bottom, white at lightness 1 to black at lightness 0.
- Primary and secondary colors are around the outside edge of the cylinder with saturation 1. These saturated colors have lightness 0.5 in HSL and value 1 in HSV.
- Mixing these saturated colors with black (shades) leaves saturation unchanged.
- In HSL, mixing with white (tints) leaves saturation unchanged.
- In HSL, mixing with both black and white (tones) reduces saturation.
- In HSV, mixing with white (tints) reduces saturation.
YUV
YUV is a color model with luma
and chrominance
components. Sometimes YUV
is also named YCrCb
, where Cr
is the red projection plane and Cb
is the blue projection plane. It was invented when engineers wanted color television in a black-and-white infrastructure.
There are several YUV pixel formats, the recommended formats for video rendering are:
- 4:4:4 (32 bpp)
- 4:2:2 (16 bpp)
- 4:2:0 (16 bpp)
- 4:2:0 (12 bpp)
RGB/YUV
Y = (0.257 * R) + (0.504 * G) + (0.098 * B) + 16 U = -(0.148 * R) - (0.291 * G) + (0.439 * B) + 128 V = (0.439 * R) - (0.368 * G) - (0.071 * B) + 128
YUV/RGB
R = 1.164(Y - 16) + 1.596(V - 128) G = 1.164(Y - 16) - 0.391(U - 128) - 0.813(V - 128) B = 1.164(Y - 16) + 2.018(U - 128)
Blend Modes
Blend modes are used to determine how two color layers are blended with each other.
Blend Modes
Normal
Mixes two layers by applying alpha blending.
α0 = αa + αb(1 - αa) C0 = (Caαa + Cbαb(1 - αa)) / α0
Dissolve
Mixes two layer by taking random pixels from both layers using a diffusion dither pattern based on alpha.
No anti-aliasing is used so the result looks grainy.
Multiply
Mixes two layers by multiplying the values.
Since color values are in the range [0,1]
, the result will be less than each initial value.
Multiplying a color by black produces black. Multiplying a color by white produces the same color.
If a layer contains homogeneous value, multiply is equivalent to using normal with the value as opacity and a black bottom layer.
C0 = CaCb
Screen
Mixes two layers by inverting, multiplying and inverting again the values.
Screen is the opposite of multiply.
If a layer contains a homogeneous value, screen is equivalent to using normal with the value as opacity and a white top layer.
C0 = 1 - (1 - Ca)(1 - Cb)
Overlay
Combines multiply and screen.
If the base layer is light the result is lighter. If the base layer is dark the result is darker.
An overlay with the same picture looks like an S-curve.
2CaCb if a < 0.5 C0 = 1 - 2(1 - Ca)(1 - Cb) otherwise