Colour in images
There are three type of colour specification in images. These are monochrome, palette
based colour and true colour. These are dealt with individually below:
Monochrome images
A monochrome image typically can display only black and white pixels, though on
some systems these may be substituted by other colours (e.g sepia & white or
black & green). The key feature of a monochrome format is that each pixel only
requires 1 binary digit of data to represent it. Since 1 byte = 8 bits, we can see
that a 1024 by 768 monochrome image would only require 1024 x 768 / 8 bytes (or
96KB) of storage (before compression).
Palette based colour
With palette based colour a limited number of colours (usually 256) can be displayed,
though each colour can be individually set to one of an almost indefinite number
of colours. This is achieved by storing a table listing all the colours inside the
image file. With a 256 colour palette we only need one byte of data for each pixel
(1 byte has 256 different combinations of data). When the display needs to display
the image it looks up the actual colour for each pixel from the palette table
in the file.
This technique is effective for images with a reasonably small colour variation,
and so tends to be used for drawings and images produced using painting software.
The images below show a complex image with its corresponding palette. Notice that
the palette for this image still has three spare entries, so the image must only
require 253 different colours.
True Colour
With true colour each pixel is represented by a piece of data which represents the
amounts of Red, Green and Blue that should be mixed to give the required colour.
The most common format is to use 3 bytes of data, with one byte for each of Red,
Green and Blue. This means there are 256 different levels of each colour (0 to 255),
giving a total of 256x256x256 colour combinations (around 16 million). It is impractical,
if not impossible,
for a graphics editing program to provide a user interface which can display all
16 million possible colours for a 24bit true colour system, so this is usually done
using a composite colour picker. The following image shows a simple
example of such an interface, although some software packages have much more complex
and versatile dialog boxes for setting colours:
Sometimes a 16bit (2 byte) version is used. This allows for 6 bits (64 values) for
each of Red and Green and 4 bits (16 values) for Blue. Since the human eye is less
sensitive to levels of blue in an image the lower number of blue values is not discernable.
This allows for 64 x 64 x 16 different colours (65536).