The concept of colour can be approached from many angles, including mathematics. Image: Wingchi Poon.

How does a computer understand the colours to be displayed on the monitor's screen? As we will see, for a computer to understand colours, they must be turned into numbers written in a special way. So, before we can talk about colour, our first task will be to review a few things about numbers.

Writing numbers in special ways

The meaning of the symbol 222 is in the words we use to name it: two hundred, twenty (or two tens) and two. These words tell us that 222 means

$2 \times 100+2 \times 10+2$


$2 \times 10^2+2 \times 10^1+ 2\times 10^0.$

That is, 222 is written in a special way using what we call the decimal system, which has base 10 and the digits 0, 1, 2, 3, ..., 9. Our base ten system is a positional system, meaning that the value of a particular building block depends on the power of 10 that goes with it. In our example 222, we see that the symbol 2 repeats three times, with a different value in each occurrence.

As familiar as this setting feels to us, there is really nothing special about it. We could reproduce the same process with a different base and appropriate digits. For instance, if we agree to work with base, say, 4 and digits 0, 1, 2, 3 the symbol 222 will now mean

  \[ 2 \times 4^2 + 2\times 4^1 + 2 \times 4^0. \]    

Performing this calculation, we end up with the base ten number 42. So

  \[ 222_4=42_{10}, \]    

with the subscripts indicating the base. We could also find out what number in base 4 is equal to $222_{10}.$ In fact,

  \[ 222_{10} = 3 \times 4^3 + 4^2 + 3 \times 4^1 + 2 \times 4^0 = 3132_4. \]    

Many interesting questions can be explored in any given base: How do we recognise an even number? An odd number? What are the addition and multiplication tables? And so on. But we should not dwell too much on this number preamble, because our purpose, remember, is not to play with different number systems. Our purpose today is to look at colour as a computer understands it.

What is colour?

Etymologically, colour is akin to the Latin word celare, which means to conceal. As for its meaning, we say that "her story has the colour of truth", or that "colour is the daily bread of the eyes", we remark on "the colour of the cello" or we state that "a surprising number of animals can change colour to match their surroundings". In each of these sentences, the word colour has a different meaning. In fact, a dictionary will list no less than ten meanings of the word colour.

For our purposes, colour will be what the dictionary defines as "a visual perception that enables us to differentiate otherwise identical objects". We could approach this concept of colour from several disciplines: physiology, psychology, philosophy, physics, chemistry, art and, yes, mathematics.

How can we describe colour?

Starry night

Van Gogh's famous painting Starry night.

Artists refer to colour using three attributes, hue, saturation (or intensity) and luminosity (or value). Hue answers questions such as "Is it red?". Saturation describes a colour as bright or dull, while luminosity points to whether it is light or dark.

Colour is a very subjective perception. What is green or yellow or blue or purple very much depends on the observer. Even if two people looking at a wall agree that it is white, still neither one of them will ever know whether both see the same thing. And the red of Georgia O'Keffee's poppies or the blue of Van Gogh's Starry night speak to us also of the artist's emotional meaning. However, if colours are to be displayed on a computer monitor for instance, they have to be understood by a device far removed from any subjective sense of emotion, a device that is able to process data only by means of very specific commands. So, how does a computer deal with the colours we see on the monitor's screen?

The RGB system

There is more than one system that computers can use to describe colour, but the most popular one might be the RGB system. We can see it at work when selecting the appearance of the display in the control panel of a PC:

Colour picker dialogue

Figure 1: A colour dialogue box.

The name RGB stands for Red, Green, Blue, meaning that this system produces a colour as a mixture of three colours: red, green and blue. The numbers from 0 to 255 are used to indicate how much of each of these three colours is in the mixture. For instance, 255 0 0 is pure red, while 0 255 0 is pure green and 0 0 255 is pure blue. You might not think of them as the most typical red, green or blue, but here they are:

Red, green and blue

Figure 2: Pure red, green and blue.

From black, 0 0 0, to white, 255 255 255, the RGB system allows for 256 × 256 × 256 = 16,777,216 colours. This number is plenty, considering that the human eye can recognise about ten million different colours. Nature is capable of displaying many more colours.

One thing to notice is that the computer not only gives us the colours in the RGB system, but it also produces a numerical correspondence between the quantities of red, green and blue, and the artist's attributes of hue, saturation and luminosity. To avoid the complication of putting these three attributes in a three dimensional display, the computer breaks them down into a plane for the hue and the saturation (the coloured square in figure 1) and a line for the luminosity (the vertical strip in figure 1).


Figure 3: The colour 210 70 4.

Are we there yet? Not quite. The RGB system is just the beginning of how a computer deals with colour, because at the most basic level, the only commands a computer understands are the turning on and the turning off of an electric current. Ultimately, every piece of data and every instruction that is entered in a computer has to be written as a combination of these ON/OFF basic commands. A natural numerical model that represents these commands is

$ ON \rightarrow 1,$

$OFF \rightarrow 0.$

That is to say, for computer consumption a colour such as 210 70 4 (shown in figure 3) must be given as a combination of ones and zeros. In other words, the numbers 210, 70 and 4 have to be written in the binary system (or in base 2):

  $\displaystyle 210  $ $\displaystyle  =  $ $\displaystyle  2^7 + 2^6 + 2^4 +2 = 11010010_2 \nonumber  $    
  $\displaystyle 70  $ $\displaystyle  =  $ $\displaystyle  2^6+2^2 +2 = 1000110_2 \nonumber  $    
  $\displaystyle 4  $ $\displaystyle  =  $ $\displaystyle  2^2 = 100_2. \nonumber  $    

So, our rusty orange is ultimately the following sequence of ON/OFF commands:





















You might have wondered why the RGB system uses the scale 0 to 255. Here is why: Observe that

  $\displaystyle  255  $ $\displaystyle = $ $\displaystyle  2^7+2^6+2^5+2^4+2^3+2^2+2+1  $   (1)
  $\displaystyle  $ $\displaystyle  =  $ $\displaystyle  11111111_2. $   (2)

This means that if we start with the necessary number of zeros, every number from 0 to 255 can be represented in the binary system by a string of eight zeros and ones. For instance,

  \[ 0=00000000_2 \]    


  \[ 1=00000001_2. \]    

So, we write

  \[ 210 \; \; \;  70 \; \; \;  4=11010010\; \; \;  01000110\; \; \;  00000100. \]    

Each one or zero is called a bit and each group of eight bits is called a byte. In computer science, a byte is a unit frequently used to give the size of data. This explains why the RGB system chooses the scale from 0 to 255 to represent each of red, green and blue: every colour in this system can be given as three bytes.

A huge topic that we will not touch is the chemical mechanisms by which the colours actually appear on the monitor's screen.

Now we can see that a computer, indeed, colour by numbers. Binary numbers, that is.

A bit more

Although we have answered the question we set to consider, two interesting points have crept up along our discussion: the meaning of number and the objectivity of a computer.


Figure 4: Paper clips.

We have seen that $222_{10}$ and $3132_4$ are the same thing and we could check that this thing is also $11011110_2$. So, when we speak of a number, perhaps what we really mean is the collection of all its representations, which, by the way, do not need to be numerical, as proved by the 222 paper clips on the left.

Of course, our familiarity with the decimal representation makes it, undoubtedly, the preferred one. But the question still remains: What is this abstraction that we call number?

Once we think of numbers in terms of representations, another issue pops up: properties such as being even or being odd should be independent of the representation. This is indeed the case, as there are ways of recognising even numbers and odd numbers in any given base. For instance, in base ten, even numbers are those ending in 0, 2, 4, ... , 8, while odd numbers are those ending in 1, 3, 5, ... , 9. The rule is similar in base two: even numbers are those ending in 0, while odd numbers are those ending in 1. Can you formulate a rule that applies to all the bases 2, 4, 6, ... ? How about bases 3, 5, 7, ...? Of course, in any base, we can define a number to be even if it is divisible by 2.

Going on to the objectivity of a computer, the French mathematician Émile Picard (1856-1941) had this to say about mathematics: "We must acknowledge that the complete objectivity of our science is a chimera. Created by us using our organs, mathematics is made to fit us."

Could it be that the same can be said about the alleged objectivity of a computer?

About the authors

Josefina (Lolina) Alvarez

Josefina Alvarez

Josefina (Lolina) Alvarez was born in Spain. She earned a doctorate in mathematics from the University of Buenos Aires in Argentina, and is currently professor emeritus of mathematics at New Mexico State University in the United States. Her long time interest is to communicate mathematics to general audiences. She is on the editorial board of Matematicalia and writes the column What if...?. Lolina likes to hike, and with husband Larry and dogs Brandywine and Sofia, she has walked many kilometres along the beautiful trails of New Mexico and elsewhere.

Claudia Gómez

Claudia Gómez

Claudia Gómez Wulschner was born in Mexico City. She studied mathematics at the UNAM (National University of Mexico), obtaining both her M.Sc. and Ph.D. in Mathematics at Washington State University. Since 2000 Claudia has been a full-time profesor at the Instituto Tecnológico Autónomo de México (ITAM). Claudia has had almost thirty years teaching experience. She belongs to the SNI (mexican national system of researchers). Her research articles are mainly in the area of functional analysis, but she has also written for a general audience. She has co-authored mathematics textbooks. Two for Elementary School, more than twelve for Middle and Junior School and some of them with additional material for teachers.