Visual Analytics and Colour Models
INTRODUCTION
This section presents a discussion of colours and how they are represented. Consider an image with a specified number of rows and a specified number of columns. The image is a 2D matrix along its two dimensions: rows for height, and columns for width. Each cell, or element, in that matrix is called a pixel, or picture element. Each pixel in the image contains a colour value. Greyscale images consist of a single colour value. If a continuous scale is used, this colour value ranges from zero (0), indicating black, to one (1), indicating white. If 8-bit values are used to represent colours, then zero indicates black and 255 represents white, as there are 256 values in an 8-bit colour (28 = 256). For colours, various colour models in addition to greyscale exist. The most common colour model is the RGB (Red, Green, and Blue) model. Other colour models include HSV (Hue, Saturation, Value) or HSL (Hue, Saturation, Lightness), and CMYK (Cyan, Magenta, Yellow, Black [K]) . Other colour models exist as well. The RGB colour model is the most common and is widely understood. In the RGB model, there are three channels: one each for red, green, and blue. In addition, an extension to the RGB model is the RGBA model, where “A” indicates alpha, or the transparency value of a pixel. The RGB model generally represents the values for the red, green, and blue channels with eight bits, meaning that each channel has values that range from zero to 255. In a continuous RGB model, each of the three channels have values that range from 0 to 1. However, it is a very easy task to convert from an 8-bit representation to continuous values. For 8-bit RGB values, each of the R, G, and B components are divided by 255 to convert to values that range from 0 to 1. For continuous values, each channel is multiplied by 255, and subsequently rounded, or truncated. For example, suppose that a pixel has an 8-bit RGB value of [120, 30, 255] – that is, the red channel has a value of 120, and the green and blue channels have values of 30 and 255, respectively. Then,
R = 120 / 255 = 0.4706 (to 4 decimal places)
G = 30 / 255 = 0.1176
B = 255 / 255 = 1.
Therefore for 8-bit RGB values of [120, 30, 255], the continuous representation is [0.4706, 0.1176, 1].
As another example, suppose that a continuous RGB value is given as [0.15, 0.8, 0.25]. Then,
R = 0.15 × 255 = 38.25, which, when rounded, is 38
G = 0.8 × 255 = 204.0 = 204
B = 0.25 × 255 = 63.75, which, when rounded, is 64.
There, the continuous RGB values of [0.15, 0.8, 0.25] are represented in 8-bit values as [38, 204, 64].
In the RGB model, grey colours – including black and white – are indicated when all three channels have the same value. For instance, in 8-bit representations, [0, 0, 0] indicates black, [255, 255, 255] indicates white, [40, 40, 40] is a dark grey, and [220, 220, 220] is a light grey.
The CMYK colour model is another model in common usage. C indicates the colour cyan (a colo