Tag Archives: CIE

Colour Matching and Cones

Earlier today I posted something on quora about who many colours there are. It’s quite a long post. You can read it here. However, if you want the short cut the answer is 3-5 million. 🙂

However, I also linked to the post on LinkedIn and someone asked me a question about the relationship between colour-matching functions and cone sensitivities so I thought I would make a new post today about that topic. I have used my message on LinkedIn as the basis for this post but modified it a little to make it suitable for general consumption.

Here are two diagrams:

This shows the actual spectral sensitivities of the MLS cones in the human eye

The 1931 CIE XYZ colour-matching functions

It’s another common misconception that people get these two diagrams confused. The cone spectral sensitivities are the actual sensitivities of the cones in the eye. Although people often say that the eye responds mainly to red, green and blue light, it’s not so simple.  In 1931 the CIE measured the colour matching functions. One of the reasons that they did this was that in 1931 we didn’t actually know what the cone spectral sensitivities were; these were only known for sure in 1964. So in 1931 the CIE measured the amounts of three primary lights that an observer would mix together (additively) in order to match a single wavelength of light. And they did this for each wavelength. The second of the diagrams above shows the amounts of each of the primaries needed to match each wavelength on the spectrum.  Originally, the CIE used three lights (these were RGB)  or primaries. However, they mathematically transformed their RGB colour matching functions to create the XYZ colour matching functions. These are sometimes also known as the CIE colour matching functions or the CIE standard observer.

These are the original CIE RGB colour-matching functions

The point of these (XYZ) colour matching functions are that they allow us to calculate the CIE tristimulus values XYZ of an object if we know the spectral reflectance of the object and the light it is viewed in. The XYZ values are the amounts of the three XYZ primaries that an observer would, on average, use to match that object viewed in that light source. If two samples have the same XYZ values then they are a visual match; because an observer would, on average, use the same amounts of the XYZ primaries to match each. And this was the whole point of the CIE system; to determine when two colour stimuli are a visual match.  Had we known the cone spectral sensitivities in 1931 it’s possible that history would have taken a different course and that instead of having CIE XYZ we would simply calculate the cone responses LMS. And we could say that if two samples have the same cone responses they are a visual match. But I guess we’ll never know.

Now, if two samples have the same XYZ values then they will have the same cone responses. This is a bit technical but this is true because the cone spectral sensitivities are a linear transform of the CIE XYZ colour matching functions. They are also a linear transform of the CIE RGB colour-matching functions.

The colour-matching functions depend upon which primaries are used whereas the cone spectral sensitivities are more fundamental. Doesn’t this make the colour-matching functions arbitrary? Not really. Although the actual shapes of the colour-matching functions depend upon the actual primaries used, the matching condition does not. If two samples generate the same cone responses then the observer would match them with the same amounts of the XYZ primaries and the same amounts of the RGB primaries.

On this page – https://en.wikipedia.org/wiki/CIE_1931_color_space – you can see the cone spectral sensitivities and the RGB and XYZ colour matching functions.

On CIE colour-matching functions

In 1931 the CIE used colour-matching experiments by Wright and Guild to recommend the CIE Standard Observer which is a set of colour-matching functions. These are shown below for standard red, green and blue primaries. These show the amounts – known as tristimulus values – of the three primaries (RGB) that on average an observer would use to match one unit of light at each wavelength in the spectrum. Why are these so important? Because they allow the calculation of tristimulus values for any stimulus (that is, any object viewed under any light as long as we know the spectral reflectance factors of the surface and the spectral power of the light).

650px-CIE1931_RGBCMF.svg

I gave a lecture this week about these and so they are fresh on my mind. I wanted to use this blog post to explain two things about the colour-matching functions that may be puzzling you. The first was stimulated after the lecture when one of the students came up to me with a question. You will note that for some of the shorter wavelengths the red tristimulus value is negative. Hopefully you are aware that no matter how carefully we choose the three primaries we cannot match all colours using mixtures of those three in the normal sense. What we have to do is to add one of the primaries to the thing we are trying to match and then match that with an additive mixture of the other two primaries. The question from the student was, wouldn’t that change the colour of the thing that is being matched? The answer is that it would of course. But it’s ok.

We normally represent this matching with an equation:

S ≡ R[R] + G[G] + B[B]

which simply means that the stimulus S is matched by (that is the symbol ≡) R amounts of the R primary, G amounts of the G primary, and B amounts of the B primary. The values R, G and B are the tristimulus values. I put square brackets around the primaries themselves to distinguish them from the amounts or tristimulus values of the primaries being used in the match.

Now when we add one of the primaries to the stimulus (the thing we are matching) itself, we can write this equation:

S + R[R] ≡ G[G] + B[B]

The new colour, S + R[R], can now be matched by an additive mixture of the other two. Hmmmmmm? You may ask. How does that work? Well, we can rearrange this equation to make:

S ≡ -R[R] + G[G] + B[B]

In other words, matching the additive mixture of the original stimulus S and some red with some green and blue, means that – if it were possible – we could match the original stimulus S with the same amount of green and blue and a negative amount of the red. I appreciate that this is mathematical but I hope that it is maths that anyone could understand. It’s not rocket science. Just simple adding and subtracting. This is how we arrive at the colour-matching functions above. No matter what RGB primaries we use one of them will have to be used in negative amounts to match some of the wavelengths. In practice, this is done by adding it to the stimulus as described above. Of course, you may also know that the RGB colour-matching functions were transformed to XYZ colour-matching functions. These are the XYZ values everyone is familiar with. But that is another story I will devote another post to one day.

The second question though, is isn’t this just arbitrary? If we used a different set of RGB primaries wouldn’t we get a different set of colour-matching functions? Again, the answer is yes, but again it doesn’t matter. The whole point about the CIE system was to work out when two different stimuli would match. If two stimuli are matched by using the same amounts of RGB then by definition those two stimuli must themselves match. If we used different RGB primaries the amounts of those tristimulus values would change, of course, but the matching condition would not. Two stimuli that match would also require the same RGB values as each other to match them, not matter what the primaries were (as long as they were fixed of course). So the key achievement of the CIE system was to define when two stimuli would match. However, it was also useful for colour specification or communication but that does indeed depend upon the choice of primaries and requries standardisation.

I hope people find this post useful. Post any questions or comments below.

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:
 myspectrum

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.

chromdiagram

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.

 

rgb

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).

514PWPFTKXL__BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU02_

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.

CIE system of colorimetry

For about 100 years there has been an international system for colour specification – it’s called the CIE system. The acronym comes from Commission Internationale de L’Eclairage.

This system is based on the notion of additive colour mixing – http://colourware.wordpress.com/2009/07/13/additive-colour-mixing/

Since it is possible to mix together three primary lights and make a wide gamut of colours (though not, of course, all colours) the principle is that the amounts of these primaries that an observer would use to mix togther to match a colour is a useful specification of that colour. We refer to these amounts as tristimulus values. One could imagine a visual colorimeter whereby an observer would try to match a colour that is to be specified by adjusting the intensities of three primary lights that are mixed together – once a match is obtained then the tristimulus values would define or specify the colour. All that would be necessary would be to able to decide on a set of primaries and manufacture the visual colorimeters so that they are very consistent from one device to the next. It would be a little clumsy though to have to use one of these visual colorimeters. But in principle it could work.

Fortunately the CIE does not require the use of such visual colorimeters since in 1931 the CIE measured the trismumulus values that observers made when matching various colours. These were averaged to create the so-called CIE standard observer.  And here’s the really clever bit. Having defined the CIE standard observer it is possible to calculate the tristimulus values (the amounts of the three primaries that an observer would use to match a colour) without any further observations. All that is required is that we know the amount of light at each wavelength reflected by a sample or (in some cases) emitted from a device such as computer display and then – by using our knowledge of the CIE standard observer – it is possible to calculate the tristimulus values.

So what were the primaries. If you have read my previous post, What is a colour primary – http://colourware.wordpress.com/2009/07/08/what-is-a-colour-primary/ – you’ll know that the choice of colour primaries is somewhat arbitrary. Well, in fact the original determination of the standard observer what carried out in England using red, green and blue primaries. But the data obtained were later modified to refer to a different set of primaries known as X, Y and Z. It was necessary to make this adjustment because using any set of real primaries it was impossible to match any colour with mixtures of the primaries; using RGB meant many colours could be matched, but not all. So a set of so-called imaginary primaries was conceived which could – in theory – be used to match all colours. So the tristimulus values of the CIE system are known as X, Y and Z. 

In fact, it didn’t really matter which set of primaries was used; the CIE system was concerned with colour matching. If two samples have the same tristimulus values then they would be a visual colour match no matter which set of primaries was used. So the choice of primaries really was not critical.

Today many instruments are commercially available – colorimeters, reflectance spectrophotometers, radiometers) – that, with the use of software, allow the CIE XYZ values to be measured; these instruments are extremely valuable in many industrial and commercial applications. The CIE system is still very much alive today, though many users often prefer to use one of the more advanced colour spaces – such as the CIELAB colour space – which was defined by the CIE in 1976 and whose values are very easily calculated from the CIE XYZ values.  For further information about the CIE please visit their web site – http://www.colour.org/