Indexed color
This article has multiple issues. Please help improve it or discuss these issues on the talk page. (Learn how and when to remove these template messages)
|
In computing, indexed color is a technique to manage digital images' colors in a limited fashion, in order to save computer memory and file storage, while speeding up display refresh and file transfers. It is a form of vector quantization compression.
When an image is
History
Early graphics display systems that used 8-bit indexed color with
A few earlier systems used 3-bit color, but typically treated the bits as independent red, green, and blue on/off bits rather than jointly as an index into a CLUT.
Palette size
The palette itself stores a limited number of distinct colors; 4, 16 or 256 are the most common cases. These limits are often imposed by the target architecture's
Color depth |
---|
Related |
If simple video overlay is intended through a transparent color, one palette entry is specifically reserved for this purpose, and it is discounted as an available color. Some machines, such as the MSX series, had the transparent color reserved by hardware.[5]
Indexed color images with palette sizes beyond 256 entries are rare. The practical limit is around 12-bit per pixel, 4,096 different indices. To use indexed 16 bpp or more does not provide the benefits of the indexed color images' nature, due to the color palette size in bytes being greater than the raw image data itself. Also, useful direct RGB
If an image has many subtle color shades, it is necessary to select a limited repertoire of colors to approximate the image using color quantization. Such a palette is frequently insufficient to represent the image accurately; difficult-to-reproduce features such as gradients will appear blocky or as strips (color banding). In those cases, it is usual to employ dithering, which mixes different-colored pixels in patterns, exploiting the tendency of human vision to blur nearby pixels together, giving a result visually closer to the original one.
Here is a typical indexed 256-color image and its own palette (shown as a rectangle of swatches):
Colors and palettes
How the colors are encoded within the color palette map of a given indexed color image depends on the target platform.
Early color techniques
Many early
Other machines of this era had the ability to generate a larger set of colors, but generally only allowed a subset of those to be used in any one image. Examples include the 256-color palette on
RGB
Hardware palettes based on component video colors such as YPbPr or the like were generally replaced in the mid 1980s by the more flexible RGB color model, in which a given color can be obtained by mixing different amounts of the three primary colors red, green, and blue. Although the total number of different colors depends on the number of levels per primary, and on a given hardware implementation (a 9-bit RGB provides 512 combinations, a 12-bit RGB provides 4,096, and so on), in this model digital-to-analog converters (DAC) can generate the colors — simplifying the hardware design — while the software can treat the number per levels used abstractly and manage the RGB colors in a device-independent fashion. With colors stored in RGB format within the palettes of indexed image files, any image can be displayed (through appropriate transformations) on any such system, regardless of the color depth used in the hardware implementation.
Today, display hardware and
Pixel bits arrangements
Except for very low resolution graphic modes, early home and personal computers rarely implemented an "all-pixels-addressable" design - that is, the ability to change a single pixel to any of the available colors independently. Their limitations came from employing separate color attribute or color RAM areas, leading to attribute clash effects. Also, the pixel bits and/or the scan lines of the video memory were commonly arranged in odd ways convenient for the video generator hardware (thus saving hardware costs in a cost-competitive market), but sometimes creating difficulty for the people writing graphics programs. A pixel's bits in indexed-color, all-pixel-addressable images are not always contiguous in video memory or image files (i.e., chunky organization is not always used.) Some video hardware, such as the 16-color graphic modes of the Enhanced Graphics Adapter (EGA) and Video Graphics Array (VGA) for IBM PC compatibles[7] or the Amiga video buffer[8] are arranged as a series of bit planes (in a configuration called planar), in which the related bits of a single pixel are split among several independent bitmaps. Thus, the pixel bits are conceptually aligned along the 3D Z-axis. (The "depth" concept here is not the same as that of pixel depth.)
Early image file formats, such as
Some indexed-color image file formats such as
As seen here, the image has been divided into four groups of lines: group A contains every fourth line, group B contains lines immediately following ones in group A, group C likewise contains the lines immediately following those in group B, and group D contains the remaining lines, which are between group C lines (immediately above) and group A lines (immediately below). These are stored into the file in the order A, C, B, D, so that when the file is transmitted the second received group (C) of lines lie centered between the lines of the first group, yielding the most spatially uniform and recognizable image possible, composed of only two of the groups of lines. The same technique can be applied with more groups (e.g. eight), in which case at each step the next group to be sent contains lines lying at or near the centers of remaining bands that are not yet filled with image data. This method, with four or eight groups of lines, was commonly used on the early World Wide Web during the second half of the 1990s. Rather than leaving the background (black) showing as in the illustration above, the partial image was often presented on screen by duplicating each line to fill the space below it down to the next received image line. The end result was a continuous image with decreased vertical resolution that would increase to full resolution over a few seconds as the later parts of the image data arrived.
Advantages
Indexed color saves a lot of memory, storage space, and transmission time: using
Indexed color was widely used in early
Image files exchanged over the
Most
Interesting
Simple video overlay can be achieved easily through the transparent color technique.
By manipulating the color hardware registers (
Disadvantages
The main disadvantage of using indexed color is the limited set of simultaneous colors per image. Small 4- or 16-color palettes are still acceptable for little images (
Indexed color images are heavily dependent on their own color palettes. Except for a few well known fixed-color palettes (such as that of the Color Graphics Adapter—CGA), raw image data and/or color map tables cannot be reliably exchanged between different image files without some kind of intermediate mapping. Also, if the original color palette for a given indexed image is lost, it can be nearly impossible to restore it. Here is an example of what happens when an indexed color image (the previous parrot) has been associated with an incorrect color palette:
Indexed color graphic modes for display adapters have the 16- or 256-color limit imposed by hardware. Indexed color images with rich but incompatible palettes can only be accurately displayed one at a time, as in a
The following image is a mosaic of four different indexed color images rendered with a single shared master palette of 6-8-5 levels RGB plus 16 additional grays. Note the limited range of colors used for every image, and how many palette entries are left unused.
Many indexed color display devices do not reach the 24-bit limit for the full RGB palette. The VGA for IBM PC compatibles, for example, only provides an 18-bit RGB palette with 262,144 different possible colors in both 16- and 256- indexed color graphic modes.
Some image editing software allows gamma correction to be applied to a palette for indexed color image files. In general, to apply a gamma correction directly to the color map is bad practice, due to the original RGB color values being lost. It is better to apply the gamma correction with the display hardware (most modern display adapters support this feature), or as an active intermediate step of the rendering software through color management, which preserves the original color values. Only when the indexed color images are intended for systems that lack any kind of color calibration, and they are not intended to be cross-platform, gamma correction may be applied to the color table itself.
Image file formats supporting indexed color
These are some of the most representative image file formats that support indexed color modes. Some of these support other modes (e.g. truecolor), but only the indexed color modes are listed here.
- NOTE: most of the formats will also support a color table with fewer colors than the maximum that a given bit depth can offer.
Acronym | Full name | Creator | DOS extension | 1-bit (2) |
2-bit (4) |
3-bit (8) | 4-bit (16) |
5-bit (32) | 6-bit (64) | 7-bit (128) | 8-bit (256) | Compression |
---|---|---|---|---|---|---|---|---|---|---|---|---|
PCX | PC Paintbrush Image File | ZSoft Corporation
|
.pcx |
Yes | Yes | No | Yes | No | No | No | Yes | RLE |
ILBM | InterLeaved BitMap | Electronic Arts | .lbm , .iff |
Yes | Yes | Yes | Yes | Yes | Yes* (EHB mode, 64-color) | Yes* | Yes* | Uncompressed, RLE |
GIF |
Graphics Interchange Format | Compuserve
|
.gif |
Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | LZW
|
TGA | TARGA File format | Truevision | .tga , .vda , .icb , .vst |
No | No | No | No | No | No | No | Yes | Uncompressed, RLE |
TIFF | Tag(ged) Image File Format | Aldus | .tif |
Yes | Yes | Yes | Yes | Yes | Yes | Yes | Yes | Uncompressed, (**) |
BMP | Device-independent Bitmap | Microsoft | .bmp , .dib , .rle |
Yes | No | No | Yes | No | No | No | Yes | Uncompressed, RLE (***) |
PSD | Photoshop Document | Adobe Systems
|
.psd |
No | No | No | No | No | No | No | Yes | PackBits |
PNG |
Portable Network Graphics | PNG Development Group | .png |
Yes | Yes | No | Yes | No | No | No | Yes | DEFLATE
|
- * 64- (true, not EHB), 128- and 256-color modes only available for the AGA Amiga chipset.
- ** Native support for proprietary compression schemes.
- *** RLE with optional proprietary Delta-leaps.
Notes
- ISBN 1-55860-792-7.
- ^ Computer Graphics, Prof. R. Eckert, Lect. #5, February 2001, Binghamton U., N.Y.
- ISBN 9781581130522.
- ^ James Kajiya; Ivan Sutherland; Edward Cheadle (1975), "A Random-Access Video Frame Buffer", IEEE Conference on Computer Graphics, Pattern Recognition and Data Structures: 1–6
- ^ Online datasheet for the Texas Instruments TMS9918 Video Chip used in the MSX.
- ^ "The TIFF image file format specification" (PDF). Archived from the original (PDF) on 2006-10-17. Retrieved 2006-10-16.
- ^
Richard Wilton, Programmer's Guide to PC & PS/2 VIDEO SYSTEMS, 1987, Microsoft Press. ISBN 1-55615-103-9
- ^
Inc. Commodore-Amiga, Amiga Hardware Reference Manual, 1991, Addison-Wesley. ISBN 0-201-56776-8
See also
- Color depth
- List of palettes
- List of home computers by video hardware
References
- Julio Sanchez and Maria P. Canton (2003). The PC Graphics Handbook. CRC Press. ISBN 0-8493-1678-2.