Colour spaces and adding colour to grayscale images

Software Methodologies

RGB Colour Space

Colours represented as R,G,B intensities.

The space is modelled geometrically by a cube with axes R,G and B

RGB is used as it is based on the human perception of the visible spectrum - the human eye has R, G and B receptors with different sensitivity at different wavelengths

HSV colour space

H(ue)Specifies the dominant wavelength$0 \rightarrow 360^\circ$
S(aturation)High values correspond to vibrant pure colours$0\rightarrow 1$
V(alue)Brightness of colour$0\rightarrow 1$

The geometry of the HSV space

The hue is mapped cyclically, so red corresponds to both 0 and 360, so the HSV space can be modelled by a cylinder

When we map the RGB cube onto the HSV cylinder we get a subset of this cylinder in the shape of a pyramid with hexagonal base, which in turn gives rise to the cone model


Thresholding produces a binary image from a grayscale image

Easier to colour threshold in HSV space than RGB

Colour slicing
A portion of the Hue colour channel (range of wavelengths) can be isolated. For better results, also use S and V in conjunction

Isolate objects by colour:

  • Use an upper and lower threshold on the Hue channel to isolate by colour

  • Use a threshold on the Saturation channel to isolate pure colours

  • Combine the two outputs with logical AND

Specular highlights

  • RGB: very different position in space to original colour

  • HSV: similar position in Hue as specular present in Value


  • HSV: isolated in the Saturation/Value components

CMY colour space

CMY is a subtractive colour model based on mixing pigments of Cyan, Magenta and Yellow to create other colours.

The colours that are seen are part of the visible spectrum that is not absorbed by the pigments

The CMY colour space can be modelled by a cube

CMY colour

CMYK colour space

CMYK is an extension of CMY, with the addition of K, which is pure black and absorbs all light in the visible spectrum.

In CMY the black can also be generated by mixing all the colours, but due to pigment imperfections, is not as dark as black ink. For this reason CMYK has better contrast.

L*a*b colour space

L*a*b is a perceptually uniform colour space. Changes in the L*a*b values are commensurate with changes in human perception of colour.

L*a*b colours are specified through properties of light (distributions of wavelengths) and thus, unlike RGB, do not depend on the device that generates them

Extends RGB and CMYK. Covers all visible colours and its parameter space can specify non visible colours.

Adding colour to grayscale images

Intensity Slicing

Consider the intensity levels


where $l_0$ corresponds to black and $l_M$ to white

We use the M colours


and a pixel with intensity s is assigned the colour $c_k$ if

$$l_k\leqslant s<l_{k-1}$$

while $l_M$ is assigned $c_{M-1}$

Transfer functions

More general technique for colour mapping

  • Scalar value s; colour value c

  • Colour transfer function: $f(s)=c$

Any functional expression can map s into values for the colour components $c_1,c_2,c_3$