Tag Archives: RGB

How many colours are there?

I sometimes begin a series of student lectures on colour with the question – how many colours are there? At least one student always answers: three! In fact, this week in my lecture when I asked this question the first three or four answers were all three.

I can see where the idea of three comes from since the number three is ubiquitous in colour. We have three different classes of cones in the retina of our eyeballs – each with maximum sensitivity at a different wavelength. As a direct consequence of this trichromacy we use colour monitors with three primaries (RGB), colour printers with three primaries (CMY – ok, sometimes black as well but there’s a good reason for that), and there is a misconception that there are three primary colours from whose mixtures it is possible to make every other colour – see http://colourware.wordpress.com/2009/07/08/what-is-a-colour-primary/

I think that the number of colours that we can see is about 10 million; maybe less, but certainly millions. However, there are arguments that the true number may be much greater than this. See, for example, Mark Fairchild’s article – http://www.cis.rit.edu/fairchild/WhyIsColor/files/ExamplePage.pdf.

However, even the people thinking about colour mixing and three primaries must surely be aware that they have seen more than three colours. Indeed, were probably wearing more than three colours! So why do they respond with three? Well, it could be that they misunderstand the question and think I am asking about primaries (perhaps because they think the real question I am asking is too hard and nobody in their right mind would ask it). Or it could be that they equate the word colour with physical colorants. One of the most interesting – but also frustrating – things in field is that even the name of the field – colour – means different things to different people. Is colour something physical? Is it something you experience? Or is it simply whether something is red, yellow or blue etc; in other words, another term for what I would call hue?

This probably explains why we find the following text on this webpage – http://english.kompas.com/read/xml/2009/10/29/06125368/The.Shrimps.That.Can.See.in.Twelve.Colors:

A juvenile Mantis shrimp. These shrimps have the most complex vision systems known to science. Special light-sensitive cells allow them to distinguish between different types of polarized light, and they can see 12 colors (compared to three for humans) ranging into the near-ultra violet to infra-red parts of the electromagnetic spectrum.

It literally says that shrimps see 12 colours whereas, elsewhere on the page, it says that humans see 3 colours.  Despite this irritating lack of precision in the writing the article is quite interesting and describes the surprisingly complex nature of shrimp colour vision.

chromaticity diagram and RGB gamut

You may well have seen a typical diagram showing the chromaticity diagram and the gamut of an RGB monitor. The gamut is a triangle, of course, with the vertices formed by the chromaticities of the RGB primaries. See, for example, http://colourware.wordpress.com/2009/10/04/subtractive-mixing-why-not-rgb/.

However, that triangle is a little misleading. One problem is that we are only looking at the maximum chromaticities available – this does not imply that all of these chromaticities are available at every luminance level. Take the very vertices of the triangle – these occur for the RGB values [255 0 0], [0 255 0] and [0 0 255]. The luminance of the pure red [255 0 0]  might be 27 cd/m2, of the pure green [0 255 0] 56 cd/m2, and of the pure blue [0 0 255]  might be 6 cd/m2. (These are luminance values for a typical RGB monitor – your monitor will vary a little from this and depending upon your settings.) This means that the chromaticities of the points of the triangular gamut are only available at these respective luminance levels.

For the monitor just described the maximum luminance would be obtained when RGB = [255 255 255] and the luminance of this white would be 89 cd/m2. So for very high luminances the gamut is tiny since to achieve these high luminance values you need to have all three RGB guns firing and hence by definition the colour is going to be very desaturated.

For the typical monitor described above I have calculated the gamut of colours available at three luminance levels: 10 cd/m2, 40 cd/m2 and 70 cd/m2. I have plotted these below and coloured bright red the chromaticities that cannot be obtained at that luminance. So, for example, at 10 cd/m2 you can obtain most chromaticities but not the pure blue. The reason for this is the pure blue [0 0 255] would be only 6  cd/m2 – to get 10 cd/m2 you need to add a little red or green and this desaturates the blue.

At 40 cd/m2 you can obtain a much smaller gamut and at 70 cd/m2 the gamut obtainable is very limited. To get such high luminances on this typical RGB monitor you would need high R and G values and that gives you yellows and yellowish whites.

The point of all this is that gamuts are three dimensional and looking at the gamuts in a 2-D chromaticity diagram can be very misleading.














subtractive mixing – why not RGB?

In a previous post I spoke about the difference between additive and subtractive mixing and why the additive primaries are red, green and blue or RGB for short – http://colourware.wordpress.com/2009/07/13/additive-colour-mixing/

The chromaticity diagram – see http://colourware.wordpress.com/2009/09/28/colourchat-audiovisual-guide-to-the-chromaticity-diagram/ – has a very useful property. If you plot the chromaticities of two lights, then the straight line that joins the two points on the chromaticity diagram show you the additive mixtures that can be obtained by mixing together the two lights. If we take three lights, then the additive mixtures that can be obtained are defined by the triangle that is formed if the chromaticities are the vertices of the triangle. Ok – that’s a bit of a mouthful so let’s have a practical example. The triangle in the diagram below shows the gamut that can be achieved when we have three additive primaries that are positioned at the corners of the triangle.


 From this diagram it should become obvious why the additive primaries are RGB. Say, we chose, two reds and a cyan as the three additive primaries – well, the triangle would be tiny. In other words, the gamut would not be very big. The biggest triangle in the chromaticity is one whose vertices are formed by a red, a green and a blue. WhichRGB will give the biggest triangle? I don’t know – it’s been something that has been puzzling me for the last few days and I’ll come back to this in a later post. But certainly any RGB triangle is pretty large as long as the red, green and blue primaries chosen are reasonably saturated.

So what happens if we choose RGB as the subtractive primaries? Subtractive colour mixing describes how inks and paints mix together to form colours. The first thing to point out is that subtractive colour mixing is not additive and linear – you remember I said that when you mix two lights together the colour mixtures all fall on the straight line that joins the  two points in the chromaticity diagram that represent the two lights? Well, this is only true for additive colour mixing. So to work out the gamut for subtractive systems is not an easy thing to do. However, if you do select the three subtractive primaries as RGB you’ll get a gamut that looks something like this:


Notice that the gamut is concave. Mixing red and green lights produces a nice yellow. You can test this by going into your colour-picker in software such as Photoshop or Powerpoint and setting the RGB values to be 255:255:0. You’ll get a nice yellow. But mixing red and green paints – it will give you a similar hue to yellow but you’ll get something quite desaurated; most likely you’ll get a brown. So using RGB as the subtractive primaries would not be a very good thing at all.

It turns out that additive and subtractive colour mixing are very related. The best subtractive primaries are the ones that control the amount of red, green and blue light reflected. A yellow dye applied to textiles, for example, mainly absorbs short wavelengths in the blue section of the spectrum, allowing the other wavelengths to be reflected by the textile. The “other wavelengths” that are reflected give yellow. But the important point is that the yellow dye absorbs blue. Similarly, a magenta dye absorbs green and a cyan dye absorbs red. This leads to the idea of the optimal subtractive primaries being those that are cyan, magenta and yellow or CMY. This leads to a gamut somewhat like this:


The biggest gamut for subtractive mixing is obtained by using CMY as the primaries. But weren’t you taught at school that the subtractive primaries are red, blue and yellow? Almost certainly you were – and this is because it is accepted dogma at most art colleges and in many art and design textbooks. But it is quite easy to show that the optimal primaries – those giving the largest gamut – are CMY not RBY. If you were building a colour-reproduction system using only three colours such as a printer you would come to the conclusion – as companies such as HP, Xerox, and Epson have done – that you get the largest colour range with CMY. So why has it become commonplace for artists to refer to red, yellow and blue as the primaries? Could it be a colour naming and language issue – that they really mean cyan when they say blue and it’s just a naming error. Possible, but not likely in my opinion.  I think it is more likely that most artists are not overly concerned that RYB gives a smaller gamut than CMY because they rarely restrict themselves to three primaries. An artist would typically use 6 or more primaries. For example, they might use two blues (one that is reddish and one that is greenish), two reds (one that is yellowish and one that is bluish) and two yellows (one that is greenish and one that is reddish) in order to easily be able to mix a wide range of colours. The (mis-)identification of RYB as the subtractive primaries has much to do with colour wheels. I like to keep each of these blog posts reasonably concise – if I start writing about the problems of colour wheels now I will be writing for another 2 hours. And it’s nearly midnight now so colour wheels will need to wait for another day!

What is a colour space?

In my job I probably use the phrase “colour space” every day and have done for the last 20 years. So imagine my surprise when I was talking with a colleague recently and after a few minutes he said “Can I stop you for a second there Steve – when you say colour space, what exactly do you mean?”.

A colour space is like a map. A map of New York, for example, shows the location of various landmarks with reference to the xy coordinates (the position in horizontal x and vertical y units on the map). A colour space or colour map does the same thing with colours. Perhaps the simplest colour space is the spectrum, see below:

As we look from right to left on the spectrum the wavelengths changes from around 700nm on the far left to about 400nm on the far right. So this map shows colour with reference to wavelength. Although it is a commonly used colour space it is limited because it only really describes how hue changes with wavelength. Hue is only one of three ways in which colour can change or vary.

The most well-known really useful colour space then is the CIE chromaticity diagram – see below.


The CIE chromaticity diagram shows colours arranged on a 2-D plane. We can easily refer to any colour by how far from the left it is (the x coordinate) and how far from the bottom it is (the y coordinate). This space only shows two of the dimensions of colour; the hues are arranged in a somewhat circular way and the colourfulness increases as we move outwards from the white point (a position near to the centre of the diagram). However, we can also consider the third component of colour (brightness) if we imagine a dimension coming out of the page towards you (http://colourware.wordpress.com/2009/07/18/cie-system-of-colorimetry/). The CIE defines several different colour spaces; the CIELAB colour space, for example, is another 3-D space that defines a colour by its L*, a* and b* values.

It is useful to think of an image-display device as also having a colour space. Consider the display on which you are probably reading this blog. The display shows colour by changing the amount of the red, green and blue light emitted at each point on the screen. The diagram below is a representation of what the RGB colour space of your display device may look like.



In the RGB cube, black is in the bottom left. As the RGB values increase colours are created and white results from each of the RGB primaries at full strength. So the RGB colour space defines the relationship between RGB values and colour. However, here’s the really interesting thing: The colour space for different display devices is very different. Even if we take a single device – such as the one that you are reading this blog on – then as we change settings (the brightness, the contrast, the gamma, the colour temperature, etc.) then the colour space changes. That is, the relationship between RGB and colour changes as you change those settings. This is a huge problem. Imagine if there were many maps of New York and each showed the position of, say, the Empire State Building to be in a different position. How confusing would that be? Well, that’s the problem with colour-display technology. If we didn’t do anything about this problem then every time we looked at a colour image on a different display device the colours could change markedly. This is why we need colour management. Colour management can make compensations to the RGB values that are sent to each display device so that the colours always appear the same (well, nearly the same). To make this compensation the colour management software (which is embedded in your Windows or Apple operating system) needs to know about the colour space of each device connected to the computer. Each device needs to have a profile that describes the relationship of its own colour space with respect to some standard colour space. 

How good is colour management? Well, that depends upon many factors. Most printers, cameras, scanners, and screens (LCD, CRT, etc.) come with a driver that includes a crude colour profile. This ensures that there is a basic level of colour management and for a great majority of users this is more than adequate. However, if you want better performance then you need to think about making some measurements that will allow a more accurate colour profile to be built. In a recent blog I described a new device that you can buy to enable you to do this – http://colourware.wordpress.com/2009/07/29/colormunki-colour-management/. There are many such devices on the market. I highly recommend Andrew Rodney’s book Color Management for Photographers which is both clear and accurate (though the edition I have works on Adobe’s CS2 package whereas the latest package is CS4).


However, no matter how hard you try, colour management is never likely to be perfect. This is because different devices have different colour gamuts; a printer is likely to be able to display some colours that your display physically cannot and vice versa.

colour picker pen design


The idea is that you can use this pen to point at any object in the world, the pen then ‘extracts’ the colour, and then is able to write in that colour using a mixture of RGB inks that it contains.

Unfortunately, it’s just a concept, designed by Jinsu Park.


As far as I know there are no practical implementations of this interesting idea. One could make a strong argument that the pen should use CMY (or even red, yellow and blue) primaries since RGB primaries would result in a tiny colour gamut and wouldn’t allow the pen to reproduce any real colours at all. See http://colourware.wordpress.com/2009/07/08/what-is-a-colour-primary/

automatic extraction of colour palette from image

I just came across another interesting colour site – www.colorexplorer.com

This site provides a free service – you can upload an image and the site will extact a colour palette from the image (you can specify how many colours you wish to extract). Palettes are notated in hex codes and RGB values.

I just tried with with one of my images and chose to extact three colours; the result is shown below:



If you want to use a photograph as an inspiration for interior design, for example, you can write down the RGB values and then go to www.easyrgb.com – this site allows you to convert RGB values into commercial paint codes.

What is a colour primary?

I try to keep my blogs short. But this is going to be difficult!

Let’s start with what a primary is not. The primaries are often quoted as being red, yellow and blue. And on the BBC website – of all places – it says “Primary colours are three key colours – Red, Yellow and Blue. They cannot be made from any other colour”. For the BBC site visit http://www.bbc.co.uk/homes/design/colour_wheel.shtml.

The statement that primary colours cannot be made from any other colour is simply not true. Further, it gives the mistaken impression that there is something special about these primaries (red, yellow and blue) that makes them stand apart from the other colours. Another false statement that one often sees even in quite scholarly work is that any colour can be made by the mixture of three primary colours.

What is true is that if we select three appropriate colours and mix them together we can make a suprising range of colours. These colours – let’s call them primaries – can combine to make a huge range of different colours but unfortunately there are no three primaries that can be selected such that in mixture they can create any other colour. Depending upon the choice of primaries the range (or gamut) of colours that can be created in mixture is larger or smaller. What makes a good set of primaries? Well, I think it is reasonable to say that a good set of primaries is one where the gamut of colours that can be created is large; indeed, I would argue that the optimal primaries are those that create the largest possible gamut.

There are certain sets of primaries that can easily be predicted to give a small gamut. For example, if any of the primaries are dull and desaturated then the gamut will not be very big. Also, if the three primaries are similar to each other then the primaries are not likely to be a good set. And finally, if it is possible to combine two of the primaries together to make the other one then the gamut will be tiny. This is where – I believe – the misleading statement on the BBC website comes from; for a good set of primaries it is important that the primaries are independent (that two cannot be mixed to match the other one) but this is a long way from the BBC statement. Once we havs selected three suitable priamries then it’s true that they cannot then be made by any other colours that the primary system can make – but to argue that this is why they are primaries is clearly a circular argument.

There is nothing special about red, yellow and blue. In fact, they are not even the optimal primaries! To say what the optimal primaries are we need to specify the type of mixing: additive or subtractive. Additive mixing describes the behaviour of light-emissive systems such as computer displays, subtractive mixing describes how paints and inks mix. For subtractive mixing the primaries are often quoted as red, yellow and blue, as in the BBC article. However, a larger subtractive gamut is obtained if we use cyan (instead of blue) and magenta (instead of red) – see figure below.


One of my current research interests is to understand why red, blue and yellow became known as the artists’ primaries when a larger gamut is obtained if a bluish red is used (something closer to a magenta) and if a greenish blue is used (something closer to cyan). One only has to look at the primary colours used in inkjet printers for example (where the manufacturers have a vested interest in being able to create a large gamut) to realise that cyan, magenta and yellow are the optimal subtractive primaries.

For additive colour mixing the optimal primaries are red, green and blue. The additive and subtractive primaries have an interesting relationship – but that’s for another blog, another day.