Color Theory and Color Spaces

Last update: 2022-03-29 08:59:33 +0800 +0800
Available translations: 日本語 / 中文(简体) / 中文(繁體)

Color theory becomes practical as soon as software has to map numbers to visible output. The underlying physics is simple, but the perceptual model is not.

Cone Responses #

Human vision uses three cone-cell classes, usually called L, M, and S for long, medium, and short wavelength sensitivity.

Response strength of the three cone cell types by wavelength

  • L cones respond most strongly around 564–580 nm.
  • M cones respond most strongly around 534–545 nm.
  • S cones respond most strongly around 420–440 nm.

Cone distributions vary across people, thus the same spectrum can produce slightly different perceptual results. The ratio of L and M cones varies a lot between individuals, while S cones make up only a small fraction of the total, often around 2%.

The brain does not recover a single wavelength; it estimates color from the pattern and strength of cone responses. Under optimal conditions, human vision can extend to roughly 310 nm in the ultraviolet and 1100 nm in the near infrared, although those limits are not sharp.

Additive Mixing #

Light sources add. A 650 nm beam and a 540 nm beam do not merge into a new beam with an average wavelength; they still stimulate the eye at their own wavelengths.

That is why two different spectra can look identical. A perceptual match does not require identical physical spectra, only identical cone responses.

Magenta is the canonical example: it is a valid perceptual color, but not a single wavelength on the visible spectrum.

Color Spaces #

A color space is a coordinate system for color values, together with a definition of the gamut and transfer behavior.

sRGB #

sRGB is the default color space for the web and for many UI toolkits. It is based on RGB primaries plus a nonlinear transfer curve, thus it is convenient for devices but not perceptually uniform.

HSL #

HSL separates hue from saturation and lightness, thus it is easier to reason about than raw RGB when a task is “pick a redder color” or “make it less vivid.” The tradeoff is that equal numeric steps do not correspond to equal perceptual steps.

HSV #

HSV is similar to HSL, but replaces lightness with value or brightness. It is often useful in color pickers because it matches the way users describe paint-like adjustments.

Gradients #

Linear interpolation in RGB is simple, but it often produces muddy midpoints because RGB is not perceptually uniform.

When the goal is a smooth visual progression, the interpolation space matters more than the formula itself. A gradient should be evaluated in a space whose axes better match human perception, thus the intermediate colors feel evenly spaced.

References #

  • sRGB transfer and gamut definitions
  • CIE cone-response data
  • Practical color pickers that expose HSL or HSV controls

Comments

Read or comment on GitHub (sign-in required to comment)