Areas, Text and Colours (Introduction to Computer Graphics Using Java 2D and 3D) Part 3

Colour Models

The human eye can see light starting with a wavelength of about 300-400 nm (violet) up to roughly 700-800 nm (red). From the theoretical point of view, a colour is defined by the distribution of the intensities over the visible spectrum of the light. For colour perception, the human eye has three different types of receptor. Each receptor type is more sensitive to a certain smaller range of the spectrum. They are called red-, green- and blue-receptors. The blue-receptors are in general less sensitive than the other two. The main characteristics of a colour for human perception are the following ones.

•    hue corresponding to the dominant wavelength in the spectrum of the colour,

•    saturation or purity which is high when the spectrum consists of a narrow peak at the dominant wavelength, and which is low for a flatter spectrum, and

•    intensity or lightness depending on the energy of the spectrum. The higher the energy of the single frequencies, the higher is the intensity.

Figure 4.8 shows the distribution of energies for the frequencies or wavelengths for a spectrum with a high and a low saturation. The perceived intensity depends on the average height of the spectrum.

Perception of colours is based on three components or receptors in the human eye, and also the intuitive understanding of colours is based on three components, hue, saturation and lightness. Therefore, most colour models in computer graphics also use three components to represent colours leading to a three-dimensional colour space.


There are additive and subtractive colour models. In additive colour models the colour is determined by a superposition of light of different colours. Colours are aggregated in an additive fashion, when the background itself is black or dark. A computer monitor is a typical example where additive colour models are used. The addition of all colours yields white. The situation is different for printers. Colours are applied to a white background (paper). Mixing all colours will yield black in this case.

Distribution of the energies over the wavelengths for high (left) and low (right) saturation

Fig. 4.8 Distribution of the energies over the wavelengths for high (left) and low (right) saturation

The most common colour model in computer graphics is the RGB model. Most of the monitors also work with the RGB model. The RGB model is an additive model and each colour is composed of the three primary colours red, green and blue. Therefore, three values R,G,B e[0, 1] are sufficient to specify a colour. The minimum intensity is zero, one is the maximum intensity for each of the primary colours. (0,0,0) corresponds to black, (1, 1,1) is white, (x,x,x) defines a lighter or darker grey, depending on the choice of x, (1, 0,0) encodes red, (0, 1,0) green and (0, 0,1) blue. Usually, for the coding of the intensity of a colour, one byte is used, so that each of the primary colours has 256 different levels of intensity. Instead of three floating point values between zero and one, it is therefore also very common to specify three integer values between 0 and 255 for the intensities in order to define a colour.

Not every colour can be represented exactly as an additive combination of the three primary colours red, green and blue. For this reason, the Commission Internationale de l’Éclairage (CIE) introduced a model with three artificial colours X, Y and Z, which can represent any other colour. However, finding suitable combinations of the three artificial colours to model a desired colour is not very intuitive, so that the CIEXYZ model is seldom used.

The subtractive CMY model is the dual to the RGB model and is used for printers and plotters. The primary colours are cyan, magenta and yellow. The transformation from an RGB colour to its CMY representation is given by the equation

tmpc009-191_thumb[2][2]

Figure 4.9 shows the colour cube. Each vertex represents a specific colour. For the RGB model, the origin of the coordinate system is the lower left rear vertex at the colour black. The origin of the coordinate system for the CMY model is in the upper right front vertex at the colour white. The diagonal between these vertices contains all greytones.

Fig. 4.9 RGB and CMY model

RGB and CMY model

Today, most printers do not use the CMY model. They are based on four-colour printing with the CMYK model where the fourth additional colour K is black.5 In this direct way, black is better represented than by mixing the three other colours. The transformation from the CMY model to the CMYK model is given by the following equations:

tmpc009-193_thumb[2][2]

With these equations, at least one of the four values C, Y, M, K will always be equal to zero.

The YIQ model is not based on three primary colours as in the RGB and the CMY model, but it uses the three components luminance Y and two values I and Q characterising the chromaticity, the type of colour. This colour model is also used in the American NTSC television norm. When a coloured representation has to be transformed into a grey-scale representation, for instance for black-and-white TV, the Y-component alone defines the corresponding grey-scale intensity. The transformation from the RGB model to the YIQ model is given by the following matrix:

tmpc009-194_thumb[2][2]

The property that the value Y determines the luminance or intensity directly is also helpful when computer monitors with different brightness should be adjusted, so that the colours they show are more or less the same for identical RGB values. It is much easier to adjust only the Y-value of the YIQ model than to adjust the three values R, G and B at the same time.

Fig. 4.10 HSV model

 HSV model

 

Like the YIQ model, the HSV model is not based on three elementary colours, but on the three parameters hue, saturation and value (intensity). The HSV model represents the colour space as a pyramid standing on its tip. The tip corresponds to the colour black. The hue H is given by an angle around the vertical axis. Principal colours are represented by angles, starting with red at 0°, having yellow at 60°, green at 120°, blue at 240° and purple at 300°. The saturation S of a colour ranges from zero along the V-axis to one at the sides. The value V encodes lightness. The higher V is, the lighter the colour. Figure 4.10 illustrates the HSV model.

The HLS model is based on similar ideas as the HSV model. The hue is defined in the same way as in the HSV model. The lightness is defined by a value between zero and one. The saturation depends on the distance to the middle axis representing the grey-values. The saturation is also between zero and one. Figure 4.11 shows two versions of the HLS model. Sometimes, the HLS model is interpreted as a cylinder as in the left-hand side of the figure. But sometimes the double cone on the right is preferred for the HLS model. The double cone reflects the fact that it does not make sense to speak of saturation for the colours black and white, when grey-values are already characterised by the luminance value.

Algorithms to transform colours from the HSV and the HLS model to the RGB model and back can be found in [2]. The HSV and the HLS model count as perception-oriented colour models since they reflect the intuitive perception of colours better. Specifying the parameters of a desired colour is easier with perception-oriented models than with models like RGB or CMY. For the latter models, graphic programs very often support the specification of colours by providing a colour palette.

Like the HSV and the HLS model, the CNS model is another perception-oriented colour model based on the specification of the type of the colour, its saturation and its lightness. The CNS model does not use numbers for these parameters but words. For the type of the colour, values like purple, red, orange, brown, yellow, green, blue are available including mixtures like yellowish green, green-yellow or greenish yellow. The lightness can be defined as one of the values very dark, dark, medium, light and very light. The saturation can be greyish, moderate, strong or vivid. The number of possible combinations of these expressions is much smaller than the number of colours expressible with the RGB model. But the description of the colour is much more intuitive.

Fig. 4.11 HLS model

HLS model

Next post:

Previous post: