Color

Color is a construct in the brain. It doesn’t correspond to a physical phenomenon. Mixing light waves of different wavelengths produces the perception of different colors.

A few narrow wavelength bands are perceived as distinct colors, named primary colors. Primary colors are orthogonal to each other. Mixing primary colors produces the secondary colors we perceive.

Color reaches the eye from an object 2 ways.

Emission Based

The object emits colored light directly. Adding more light gives a brighter color. All primaries together give white, absence of light gives black.

Computer displays are emission based.

Absorption Based

The object absorbs part of the incident white light and reflects the rest. Adding more colorant removes more of the spectrum, giving a darker color. Bare substrate reflects white, full colorant absorbs everything and gives black.

Print is absorption based.

Color Spaces

A color space is a model that represents colors as tuples of numbers.

RGB

RGB is an emission based color space with primaries red, green and blue.

Each cone type is maximally sensitive to a different wavelength.

  • L cones respond best to ~560 nm, red light
  • M cones respond best to ~530 nm, green light
  • S cones respond best to ~420 nm, blue light

Any visible color is the brain’s interpretation of signals from these 3 cone types firing at different intensities. RGB primaries are chosen because they align with cone sensitivity. Each wavelength band stimulates a different cone type, making them orthogonal. Any visible color can be recreated by combining red, green and blue light in the right proportions, without the full spectrum.

Each channel is an 8-bit value in [0,255][0, 255]. All channels at 00 gives black. All channels at 255255 gives white.

CMYK

CMYK is an absorption based color space with colorants cyan, magenta, yellow and key.

[0,1][0, 1]
Here:
CC
cyan, absorbs red
MM
magenta, absorbs green
YY
yellow, absorbs blue
KK

key, black ink added to deepen dark tones and reduce colored ink use

Each component is a fraction in [0,1][0, 1]. All components at 00 gives white, the bare substrate. K=1K = 1 gives black.

Cyan, magenta and yellow are the secondary colors of RGB. Each absorbs one RGB primary, so CMY is the subtractive counterpart of the additive RGB primaries.

Conversion Between RGB and CMYK

Normalize each RGB channel to [0,1][0, 1].

R′=R255G′=G255B′=B255R' = \frac{R}{255} \quad G' = \frac{G}{255} \quad B' = \frac{B}{255} K=1−max⁡(R′,G′,B′)K = 1 - \max(R', G', B') C=1−R′−K1−KM=1−G′−K1−KY=1−B′−K1−KC = \frac{1 - R' - K}{1 - K} \quad M = \frac{1 - G' - K}{1 - K} \quad Y = \frac{1 - B' - K}{1 - K}

When K=1K = 1, set C=M=Y=0C = M = Y = 0.

The reverse conversion.

R=255(1−C)(1−K)G=255(1−M)(1−K)B=255(1−Y)(1−K)R = 255 (1 - C)(1 - K) \quad G = 255 (1 - M)(1 - K) \quad B = 255 (1 - Y)(1 - K)

The RGB gamut and the CMYK gamut differ, so a round trip is not always exact.

RGB
CMYK
rgb(62, 40, 184) cmyk(0.66, 0.78, 0.00, 0.28)

Color Representation

A digital color image is stored as a multi-channel structure, one image per attribute.

Channels

  • RGB
    Maintains the intensity of red, green and blue in separate channels.
  • Luminance and chrominance
    Separates brightness (luminance) from color (chrominance) into separate channels.
Y=wr R+wg G+wb BY = w_r\,R + w_g\,G + w_b\,B

YY is a weighted sum of the linear RGB components, matching the eye’s differing sensitivity to each. CrC_r and CbC_b are the red and blue differences from luminance, scaled so each spans [−0.5,0.5][-0.5, 0.5].

Cr=R−Y2 (1−wr)Cb=B−Y2 (1−wb)C_r = \frac{R - Y}{2\,(1 - w_r)} \qquad C_b = \frac{B - Y}{2\,(1 - w_b)}

The weights follow from the RGB primaries and white point fixed by the chosen standard, defined by the ITU Radiocommunication Sector (ITU-R). Different versions define different weights.

Standardwrw_rwgw_gwbw_b
ITU-R BT.601 (SD)0.2990.2990.5870.5870.1140.114
ITU-R BT.709 (HD)0.21260.21260.71520.71520.07220.0722
ITU-R BT.2020 (UHD)0.26270.26270.67800.67800.05930.0593

Discarding Cr,CbC_r, C_b gives a monochrome image directly.

The human visual system is more sensitive to luminance than color. YCrCb can therefore preserve luminance while reducing chrominance precision or resolution.

Chroma Precision Reduction

An 8:4:48{:}4{:}4 YCrCb representation stores 88 bits for YY and 44 bits each for CrC_r and CbC_b. Each pixel uses 1616 bits rather than the 2424 bits of 8-bit RGB.

  • Luminance
    Keeps 256256 levels, so grey-level detail is largely retained.
  • Chrominance
    Keeps 1616 levels per component, so the conversion loses color detail.
  • RGB reconstruction
    Converts the coarsely quantized chrominance values back into red, green and blue. The reconstructed RGB channels therefore have fewer distinct levels than the original.

Chroma subsampling reduces chrominance sample resolution instead of bit depth. Both approaches reduce data while retaining more luminance detail than color detail.

Per-Pixel Storage

How much color each pixel holds, independent of the channel layout.

Binary

1 bit per pixel, black or white.

Grayscale

A single intensity channel, usually 8-bit.

True Color

Each pixel stores its color directly as one value per channel, typically 8 bits each.

RGB uses 3 bytes per pixel, so it supports 224=16,777,2162^{24} = 16{,}777{,}216 colors in total. CMYK needs 4 bytes per pixel, so it supports 232=4,294,967,2962^{32} = 4{,}294{,}967{,}296 colors in total.

Indexed

Each pixel is an index into a color table.

Most images use far fewer distinct colors than true color allows. A 1920x1024 image has under 2 million pixels, so at most 2 million distinct colors, against the 2242^{24} (~16 million) an RGB pixel can encode.

Storing a table of the colors actually used, then storing pointers into that table, is more storage-efficient than true color.

  • Palette length determines how many distinct colors can be used at once
  • Bits per pixel in image memory depend on the palette table length
  • The palette table is usually stored with the image, allowing a custom color set per image

For a palette of NN colors, each pixel index needs bb bits.

b=⌈log⁡2N⌉b = \lceil \log_2 N \rceil

The total storage is the index for every pixel plus the table, where each table entry holds a 24-bit RGB color.

Sindexed=WHb+24NS_{\text{indexed}} = W H b + 24 N

True color stores 24 bits for every pixel.

Strue=24WHS_{\text{true}} = 24 W H
Here:
W,HW, H
image width and height in pixels
SS
total storage in bits

Sindexed<StrueS_{\text{indexed}} < S_{\text{true}} for any realistic NN since b<24b < 24 and the 24N24N table cost is shared by all pixels.

1920
1024
8

Strue
Sindexed
pixel indices palette table

High Color

Each pixel stores its color directly in 15 or 16 bits, with fewer bits per channel than true color. 15 bits gives 5 bits per channel, allowing 32768 colors. 16 bits usually gives the extra bit to green, as 5-6-5, allowing 65536 colors. Largely historical.

Worked Example

Indexed Image Storage

A 640×480640 \times 480 image uses a palette of 256256 RGB colors. Find the storage required for indexed and true-color representations.

Solution Reveal Hide
b=⌈log⁡2256⌉=8b = \lceil \log_2 256 \rceil = 8Sindexed=640⋅480⋅8+24⋅256=2,463,744 bitsS_{\text{indexed}} = 640 \cdot 480 \cdot 8 + 24 \cdot 256 = 2{,}463{,}744\text{ bits}Strue=24⋅640⋅480=7,372,800 bitsS_{\text{true}} = 24 \cdot 640 \cdot 480 = 7{,}372{,}800\text{ bits}

The indexed representation uses 4,909,056 bits4{,}909{,}056\text{ bits} less storage.

Written by November 3, 2026 6 min read
Was this helpful?