Light and colour

Martin McBride, 2020-09-26
Tags colour rgb light
Categories pillow
In Python libraries

In this section we will look at light and colour. EWe won't go into too much detail, but it is worth having some understanding of how the eyes perceive colour, because it affects the way computers represent colour.

Visible light

Light is a form of electromagnetic radiation. Electromagnetic radiation exists on a spectrum, and takes different forms depending on the wavelength.

Longer wavelengths (such as radio waves, and infrared used by remote controls) carry less energy. Shorter wavelengths (ultraviolet, X-rays and gamma rays) carry more energy, and excessive exposure can be dangerous.

Visible light occupies a very small range of the spectrum, with wavelengths between about 400nm and 700nm. nm stands for nanometre, and 1nm is equal a millionth of a millimetre.

Light of a particular wavelength is visible as a particular colour. 700nm is red, 400nm is blue, and the visible colours form a continuous spectrum - the rainbow colours. Although we normally take of a rainbow as having 7 colours, in fact the spectrum is a continuous range of colours that blend smoothly from one to the next:

However, the spectrum only accounts for colours created by a single wavelength. In the real world, light is usually made up of a mixture of different wavelengths. For example, light that contains a mixture of many wavelengths, in equal amounts across the visible spectrum, appears to our eyes as white.


Light in the visible part of the spectrum, as we have just seen, is generally a complex mix of a large number of different wavelengths, each with different intensities.

Fortunately the way we perceive colour a little simpler than that.

The human eye contains three types of colour detecting cells, called cones, that measure the intensity of light across different, broad parts of the spectrum - the longer wavelength red end of the spectrum, the mid-range green area of the spectrum, and the shorter wavelength blue/violet end. Here is a (not scientifically accurate) illustration of the basic idea:

Each type of cone measures the average amount of light in the part of the spectrum it can detect. These detection bands overlap, and by measuring the relative amount of light in each of these bands, our brain can recreate every colour that we see.

The important fact here is that colour as humans perceive it is a 3-dimensional quantity. We can capture a colour as a set of three values - the amount of red, green and blue light in its spectrum. If we later create light with the same red, green and blue values, for example on a computer monitor, it will look like a very similar colour.

The eye also contains a second type of cell, called rod cells. Rods sense light and dark, rather than colour. They are more sensitive than cones, so they provide your ability to see in dark conditions (that is why you don't see colours when it is dark). The eye contains more rods than cones, so they can detect finer detail than cones.