Sub topic 2
Additive mixing: how screens make colour from light
This chapter explains the physics and the perception behind additive mixing, which is the process every screen uses to show colour. Later chapters cover how that process is written down as RGB numbers and hex codes. This chapter assumes you know that screens are made of pixels and that colours on a screen can be described by numbers. You don't need to know any specific colour notation yet. The code example uses basic Python.
What "additive" means
A screen is a grid of tiny light sources. Each one emits light, and the light from different sources reaches your eye together. Your visual system combines it into one perceived colour. The mixing is additive because the energy arriving at your eye is the sum of the energy from each source.
Three consequences follow from this definition:
- Adding a source never makes the result darker. More light means equal or higher brightness.
- The starting point is darkness. With no light emitted, you perceive black.
- The brightest result is a limit set by the hardware. A pixel cannot emit more than its maximum, so mixing eventually saturates at white.
Paint and ink work the opposite way, and a later chapter covers them. Keep the contrast in mind: in additive mixing you start from black and add light, and in subtractive mixing you start from white paper and remove light.
Why red, green and blue
Additive mixing needs a small set of light sources called primaries. The standard choice is red, green and blue. This choice comes from human biology, not from physics. Light has no three special wavelengths.
The retina has three kinds of cone cells that respond to light. They are usually called S, M and L cones, for short, medium and long wavelengths. Their sensitivity peaks sit roughly in the blue, green and yellow-green regions of the spectrum. Each cone type reports one number: how strongly it is being stimulated. Your brain builds colour from those three numbers.
This is the key idea. If a display can stimulate the three cone types in the right proportions, you perceive the intended colour. It does not matter which wavelengths of light did the stimulating. A display therefore needs only three primaries, chosen so that each one stimulates the cones differently enough to cover a wide range of combinations.
- A red primary mostly stimulates L cones.
- A green primary stimulates both M and L cones, with M more strongly.
- A blue primary mostly stimulates S cones.
Because no real primary stimulates only one cone type, no set of three physical primaries can produce every colour you can see. The colours a given set can produce are called its gamut. A later chapter covers gamut in detail.
The mixing rules
When you add the primaries at full intensity in pairs and all together, you get the results in this table. The code values are the 0 to 255 channel numbers used in 8-bit colour, written as red, green, blue.
| Lights that are on | Perceived colour | Code values |
|---|---|---|
| None | Black | 0, 0, 0 |
| Red only | Red | 255, 0, 0 |
| Green only | Green | 0, 255, 0 |
| Blue only | Blue | 0, 0, 255 |
| Red + green | Yellow | 255, 255, 0 |
| Green + blue | Cyan | 0, 255, 255 |
| Red + blue | Magenta | 255, 0, 255 |
| Red + green + blue | White | 255, 255, 255 |
Yellow, cyan and magenta are the secondary colours of additive mixing. They are the colours that subtractive printing uses as its primaries. This is why the two systems are linked, and why the CMYK chapter returns to this table.
Intensity matters as much as which lights are on. If you lower one primary and keep the others at full, the result shifts hue. Red at full and green at half gives an orange. Lowering all three primaries equally gives grey, because equal amounts of red, green and blue light read as neutral. White on a screen is just "all three on", and every grey is "all three on, but dimmer".
How a screen mixes light in practice
A screen does not shine three beams into the same spot. It has to mix colour in two other ways, one across space and one across time.
Spatial mixing with subpixels
Each pixel on a typical LCD or OLED panel is made of three subpixels, one for each primary, placed side by side. They are smaller than the eye can resolve at a normal viewing distance. Your eye cannot separate them, so the three small patches of light blend into one colour.
You can see this effect directly. Put a drop of water on a phone screen and look through it as a magnifier. You will see the individual red, green and blue stripes or dots. Panels differ in layout, and this matters in practice:
- LCD panels usually use RGB stripes, with a backlight behind coloured filters.
- OLED panels emit light directly from each subpixel, and some use layouts other than simple stripes. Text on these panels can show small colour fringes at edges.
- Projectors and some LED walls use the same principle at a different scale.
Spatial mixing explains why very fine detail can show colour errors. A thin white line on black one pixel wide is really a pattern of subpixels, and the arrangement affects how sharp it looks. Operating systems use subpixel text rendering to take advantage of this, which is why the same text can look slightly different on different panels.
Temporal mixing
Some displays mix in time instead. A single-chip DLP projector shows red, green and blue images one after another through a spinning colour wheel. It cycles fast enough that the eye merges them. Some panels also dim by switching a light on and off very quickly, which is called pulse-width modulation (PWM). A pixel that is on 25% of the time looks about a quarter as bright as one that is always on.
Temporal mixing can fail visibly. Fast eye movements across a colour-wheel projector can produce flashes of separate colours, called the rainbow effect. Low-frequency PWM dimming can cause flicker that some people notice, and it can show up as banding in photos or video of the screen.
Black, white and the room around the screen
The table treats black as "no light". In practice that depends on the technology.
- An OLED pixel can switch off completely, so black is very close to true zero emission.
- An LCD shines a backlight through a liquid-crystal shutter that blocks most but not all of it. Black on an LCD is therefore a dim glow, and it is easiest to see in a dark room.
The room matters too. Screens also reflect ambient light off their surface. Bright sunlight adds extra light to every pixel, so blacks look grey and saturated colours look washed out. This reflected light is additive as well. It adds to what the display emits.
White is not one fixed colour either. Three primaries at full intensity give the display's white point, and different devices have slightly different ones. Some are a little warm, and some are a little blue. Your eye adapts to the white point over a few minutes, which is why a screen with a cool white can look neutral after you have used it for a while.
Adding light is linear, but code values are not
The additive rule is a rule about light energy. If one source emits an amount of light A and another emits B, the total is A + B. This holds exactly for physical light measured in linear units.
The numbers stored in image files usually do not measure light linearly. Most images use an encoding that stores darker tones with finer steps, because human vision is more sensitive to differences in dark areas. A code value of 128 out of 255 does not mean half the light. The sRGB and gamma chapter explains the curve. For now, remember that physically correct mixing must happen on linear light values, not on raw code values.
The following Python script shows the difference. It mixes a black pixel and a white pixel the way your eye does when it blends them, for example when an image is shrunk. The script averages in linear light, then compares the result with the naive average of code values.
def srgb_to_linear(value_8bit):
c = value_8bit / 255
if c <= 0.04045:
return c / 12.92
return ((c + 0.055) / 1.055) ** 2.4
def linear_to_srgb(linear):
if linear <= 0.0031308:
c = linear * 12.92
else:
c = 1.055 * (linear ** (1 / 2.4)) - 0.055
return round(c * 255)
def add_light(*sources):
"""Add linear light from several sources, clamped to the maximum of 1.0."""
return min(sum(sources), 1.0)
# Average a black pixel and a white pixel, as when shrinking an image.
black, white = 0, 255
naive = (black + white) / 2
correct_linear = (srgb_to_linear(black) + srgb_to_linear(white)) / 2
correct = linear_to_srgb(correct_linear)
print("naive average of code values:", naive) # 127.5
print("average in linear light: ", correct) # about 188
# Two lamps adding together saturate at full brightness.
half_light = 0.5
print(add_light(half_light, half_light)) # 1.0
print(add_light(half_light, half_light, half_light)) # 1.0, clampedThe correct mid-tone for a half-bright pixel pattern is about 188, not 128. Averaging code values directly makes shrunken images, blurs and gradients come out too dark. The add_light function also shows the saturation limit: the sum is clamped at 1.0 because a pixel cannot emit more than its maximum.
Common mistakes and edge cases
- Mixing code values as if they were light. Blending, blurring and resizing on non-linear values give slightly wrong results, most visibly dark fringes around bright objects. Convert to linear light for the maths, then convert back.
- Expecting black to be darker than the display allows. On an LCD, "black" is the dimmest the panel can go. A design that depends on pure black next to dark grey can show up differently on different devices.
- Assuming every screen shows the same colour from the same numbers. The same code values drive different primaries on different devices, so the colour differs slightly. Colour spaces and calibration exist to manage this.
- Treating additive and subtractive rules as interchangeable. Mixing red and green light gives yellow. Mixing red and green paint gives a muddy brown. The rules are opposites.
- Forgetting the viewing environment. Ambient light adds to the display's output and lowers contrast. A colour choice that works in a dim studio can look weak outdoors.
Summary of the working model
- Screens emit light, and the light from several sources adds together at the eye.
- Three primaries are enough because humans have three cone types.
- Red + green = yellow, green + blue = cyan, red + blue = magenta, and all three = white.
- Colour is mixed across space (subpixels) or across time (colour wheels, PWM).
- Light adds linearly, but stored code values do not, so physical mixing must be done in linear light.
- Black is the absence of emitted light, and in practice it is limited by the panel and the room.
Exercise
A designer shrinks a photo that contains a sharp black-and-white checkerboard. Averaging neighbouring pixels by their 8-bit code values gives mid-grey 128, but the shrunken image looks too dark compared with the original viewed from far away. Explain why, and say what value the correct result is close to.
Show answer
Light adds linearly, but sRGB code values are non-linear. A code value of 128 is only about 22% of full linear light, not 50%. Black and white tiles viewed from a distance blend to 50% linear light, which corresponds to a code value of about 188. Averaging should be done in linear light and then converted back to sRGB.
Exercise
A display shows yellow using only red and green subpixels. Why does the viewer still see yellow, and what is this effect called?
Show answer
The red and green light stimulate the L and M cones in the same proportions as light near 580 nm would. The brain only receives the three cone signals, so it cannot tell the two light spectra apart. Different spectra that look identical are called metamers.