Colour models used in VTK

Multiple multi-coloured cubes arranged in a pattern.

Eighth article in a series on VTK, covering colour models.

This is article 8 in a series on VTK. The first in this series can be found here. We cover colour models used in VTK.

The following information on colour models is useful for anybody unfamiliar with the common RGB and HSV colour models. Their use in VTK was described above. Either colour model can be used to describe the same colour but one may be more intuitive for the reader.

Colour is very important to scientific visualisations. VTK uses mappings from scientific data to colour palettes to present data to the user. This lets them quickly scan an image and see important information from the input data.

Colours are described by these models using 3 floating point values; VTK uses the range [0.0, 1.0]. The first is the red/green/blue (RGB) model[1]. Methods in VTK take or return 3 floating point numbers that describe the amount of red, green, and blue, that constitute that colour. An RGB value of

  • (1.0, 0.0, 0.0) is bright red;

  • (1.0, 1.0, 1.0) is white; and,

  • (0.0, 0.0, 0.0) is black.

Increasing or decreasing all three values together will lighten or darken the resulting colour.

Colour swatches showing the effect to the resulting colour when changing HSV parameters.
Figure 1. Three rows of colour swatches showing the effect when changing HSV parameters. In each row a single parameter is varied while the others remain at maximum values. Top row: the hue varies, showing variation through red, yellow, green, and blue. Second row: A purple colour has the saturation reduced, becoming increasingly grey. Third row: The same colour as the second row instead with value reduced, becoming black.

The other model is the hue/saturation/value (HSV) model[2]. It also takes 3 parameters to describe a colour but each parameter describes different pieces of information.

The first value, hue, is what a person would likely think of as the colour. Imagine moving across a rainbow, the hue would decide whether the colour is red, orange, yellow, etc.

The saturation and value describe two different aspects of the intensity of this colour. The saturation describes how much colour there is. A saturation of 0.0 would change all colours to appear in greyscale whereas 1.0 produces the complete colour. The value describes how bright or dark the colour is. A value of 0.0 would always produce black, no matter the other values, with 1.0 the brightest.

In some places a 4th value is specified: the alpha value. This is the same no matter the colour model used. This specifies how transparent a surface is. An alpha value of 0.0 is a surface that is entirely transparent, no matter the other 3 colour values. An alpha value of 1.0 produces a surface that is entirely solid/opaque and appears as the colour specified by the other 3 values.

Continue here for a summary of important VTK commands covered in this series.