Color Palettes

A color palette is the set of colors from which a bitmap is composed. Technically, it defines the mapping from the numbers in the bitmap to the colors of the pixels on the screen. Ideally, of course, there should be a continuum of color values encompassing every possible color in nature. However, the computer would therefore have to assign each of these infinite colors an individual number, so that it could represent them internally, which would require either a continuous domain representation, or the entire set of integers. This cannot be done because the modern digital computer cannot represent an infinite number of values.

Continuous vs Discrete ColorsFortunately, the human eye also cannot distinguish the entire continuum of colors (coincidentally, this can be proven by the same mathematical reasoning as for the case of the computer above!). This allows the computer to represent an image with a fair degree of realism by taking intervals of the continuous color spectrum, and representing each interval by a single discrete value. This discrete value can be such things as the average of the color values over the interval, or one of the end values, or some other appropriately defined representative color. The smaller the interval taken, the more discrete colors are available, and the more realistic will be the final image. The representative discrete color should be chosen such that in the limit as the interval width approaches zero, the representative color is the same as the interval color.

To understand some of the terminology used in the description of color palettes, it is necessary to have a basic understanding of the binary number system used to store data in a computer's memory. If you need a quick introduction to binary numbers, click here.


Color Depths and the Uniform Discrete Palette

In computer graphics, we can choose to represent the color spectrum by a uniform distribution of color intervals. Thus, each subsequent, discrete color value represents a color interval that is shifted a uniform amount to the higher end of the spectrum from its neighbor, and is the same width as its neighbor. The number of colors in this type of scheme is referred to as the color depth of the palette. The color depth is usually denoted by the number of bits needed to represent a single color in the palette. The following is a table of typical color depths:

Color Depth

Number of Colors
1 bit 2 (Black = 0, White = 1)
4 bit 16
8 bit 256
16 bit 35565
24 bit 16777216 (also called True Color)

The color depth of an image should be chosen such that the picture is displayed with sufficient, but not excessive color detail. For example, it would be redundant to use a 24-bit color depth to represent a black and white image. This would, in fact, require 24 times as much space to store the raw data than if the image had been stored in a 1-bit color depth. Similarly, a photo-quality image, with many smooth gradients from one color to another, would look very inadequate in 1-bit color. You would only require 1/24th of the space, but the picture would not be worth looking at. 24-bit color is often called True Color because it can represent color values to approximately the same color resolution depth as the human eye.


Picked Palette - the Non-Uniform Discrete Palette

A Picked Palette
An example of an 8-bit Picked Palette
An alternative to the uniformly distributed palette is the 'picked' palette scheme. This scheme chooses colors for the palette based upon their appropriateness for the image, not because they are uniformly distributed along the spectrum. A picked palette, for example, may choose to include black, white, several greens, and a great many reds and browns, yet exclude all blue colors. Obviously, this is an efficient way of storing an image if you can isolate the colors used in an image.

The drawback of this method is that the specific palette of the image must be included with the image file. The 'palette' section of these image files references a non-uniform discrete palette entry to a uniform discrete palette entry. By referencing the picked palette to the uniform discrete palette, the computer knows exactly which colors to use in the image. This is obviously necessary, since not all picked palette images will 'pick' the same palette. The picked palette scheme is a discrete palette, which picks its colors from a larger, uniform discrete palette.


Contents | Previous - Pixel Graphics | Next - Image Compression Formats