Indexed colors
In computer graphics , indexed colors are a method of storing a raster graphic . With indexed colors, the data structure of each pixel does not contain the individual color values directly, but only an index to an entry in a so-called color table or color palette, which lists the colors used in the picture. Instead of the color value, a pixel saves the number of the table entry that contains this color value. Images that contain only a few different colors save storage space due to the small size of the color index. In particular, simple graphics or diagrams can be saved to save space. Indexed colors are used in various graphic formats as well as in old graphic standards such as EGA and VGA .
functionality
All colors used in the picture are listed in the color table, with each entry containing a color value. The color table is saved separately from the pixel data. The storage space required by the index of a pixel is specified in bits per pixel (bpp) and is a measure of the so-called color depth of the image. The color depth limits the maximum number of table entries that can be used; in the case of an image with colors indexed by bpp, there is a maximum color table size of entries.
In practice, only a maximum of 8 bpp are used, corresponding to a table size of 256 colors. Theoretically, color tables with more than 8 bpp are also possible. However, the memory savings decrease as the size of the color table increases; above a certain size, the overall memory requirement is even greater than with directly specified colors.
The number of table entries is independent of the format with which the color values are ultimately represented in the table entries; any color spaces are conceivable for these . In practice, either 8-bit grayscale values or 8 bits each for red, green and blue ( RGB ), and possibly an alpha value to indicate transparency, are also used. Occasionally, the term “color depth” is also used to describe the storage space taken up by a color value; this meaning is to be distinguished from the color depth in the sense of the storage space used for a color index.
The number of colors in a raster graphic is often artificially reduced to 256 or fewer colors in order to benefit from the lower memory requirements of the indexed colors. This method, in which the colors that are most representative of the image must be determined, is called color reduction .
example
The above scheme shows how the color table works using the example of a 5 × 5 pixel image with 2 bpp, corresponding to 2 2 = 4 table entries. Each pixel contains an index to the color table that defines the respective color value. On the right you can see the same picture without the color table; the color values are saved here directly in the pixels.
Assuming that a color for this image is represented by three RGB values of 8 bits each,
- this results in a size of the image data of (5 × 5) × (3 × 8) = 600 bits for the image without a color table.
- In the case of an image with a color table, the latter occupies 4 × (3 × 8) = 96 bits; the size of the image data results in (5 × 5) × 2 = 50 bits. In this case, the entire image is only 96 + 50 = 146 bits in size.
Color lookup table
The color lookup table ( CLUT , see also lookup table ) refers to the part of the graphics hardware that converts the indexed colors of the frame buffer into normal color values so that they can be displayed on a screen. The CLUT is thus a color table implemented using hardware. With the first graphics cards, the CLUT was still hard-wired like a ROM , today it is usually a fast memory or register set in the graphics hardware that contains the currently used color table.
Most graphic formats , which define the format of a saved graphic file, support various color depths, including both those without a palette and those with a palette. In the latter there is then a separate section for the color table, which is then sometimes also called the “(Color) Look-Up Table” or similar.
Color table rotation
Since the current color table of a hardware CLUT can be changed, very fast and simple graphic effects are possible through moving color gradients (color table rotation, color cycling). Typically, a sub-area of the color palette is cyclically reassigned with a constant repetition rate. H. "Rolled through". In this way, effects such as moving water can be achieved in particular. The effort for the processor is very low, since it only has to change the contents of a few color registers in the graphics hardware from one phase to the next and does not need to access the much larger graphics memory itself. Accordingly, this approach was particularly widespread in the early days of home computers , when such a large amount of computing power was not yet available.
The color table rotation was already possible in SuperPaint , a painting program developed in the mid-1970s. The Amiga - IFF file format is particularly suitable for the storage of complex color table rotation effects within graphics files and animations. The dynamically changing pallet areas as well as the time parameters are defined in separate data "chunks" (CCRT, CRNG or DRNG). These chunks support the asynchronous rotation of several pallet areas in different speeds and directions. Various Atari painting programs such as NeoChrome allow color table rotation effects for a certain range of palettes. The Windows 95 and 98 startup screens also used color table rotation. Here the picture was saved in a file in BMP format; an entry in the header determines the number of pallet entries to be rotated.
Such possibilities are rarely used on computers commonly used today, however, since modern graphics cards work in true color mode and are fast enough to achieve the same effects in this type of display.
literature
- James D. Foley et al: Computer graphics: principles and practice. Pp. 169-170. Addison-Wesley, Reading 1995, ISBN 0-201-84840-6
- David F. Rogers: Procedural elements for computer graphics. Pp. 8-10. WCB / McGraw-Hill, Boston 1998, ISBN 0-07-053548-5
- Richard Shoup: Color table animation. ACM SIGGRAPH Computer Graphics 13, 2 (Aug 1979): 8-13, ISSN 0097-8930