Color mapping, also known as indexed color, is an image processing technique that simplifies how color information is stored and managed within a digital image.
According to the provided reference, a color-mapped image or indexed image manages the color information by maintaining a table with a limited number of colors [1,2]. The information stored in each pixel is the relative index to a color in that table [1,2].
How Color Mapping Works
Instead of storing the full color value (like millions of possibilities in a true color image) for each pixel, a color-mapped image uses a two-part system:
- A Color Table (Palette): This is a separate list containing a predefined, limited set of unique colors. Each color in this table is assigned a unique index number, starting from zero.
- Pixel Data: Each pixel in the image doesn't store the actual color value itself. Instead, it stores the index number that points to a specific color within the color table.
Imagine it like a paint-by-numbers system. The "color table" is your box of crayons with numbered slots (the colors), and the "pixel data" is the canvas where each area has a number indicating which crayon color to use.
Components Illustrated
Here's a simple example showing how a pixel's index maps to a color in the table:
Pixel Data (Index) | Color Table (Palette) | Actual Color Displayed |
---|---|---|
0 | Index 0: #FF0000 (Red) | Red |
1 | Index 1: #00FF00 (Green) | Green |
2 | Index 2: #0000FF (Blue) | Blue |
0 | ... | Red |
Note: Hexadecimal color codes like #FF0000 represent Red, Green, and Blue values.
Why Use Color Mapping?
Color mapping is often used for several practical reasons:
- Reduced File Size: Storing a small index number per pixel is significantly more space-efficient than storing full color information (typically 24 bits or more) per pixel, especially when the color table is small (e.g., 256 colors require only 8 bits per pixel).
- Faster Processing: Operations like changing the palette can quickly change the appearance of the entire image without altering individual pixel data.
- Compatibility: Many older image formats (like GIF) and displays were designed to work with limited color palettes.
- Specific Effects: Useful for creating duotone or other artistic effects by carefully selecting the colors in the palette.
While modern true color formats and compression are widespread, color mapping remains relevant for specific applications, legacy support, and formats like PNG-8.