Palette (computing) - Adaptive Versus master Palettes

Adaptive Versus master Palettes

When using indexed color techniques, real life images are represented with better fidelity to the truecolor original one by using adaptive palettes (sometimes spelled adaptative palettes), in which the colors are selected or quantized through some algorithm directly from the original image (by picking the most frequent colors). This way, and with further dithering, the indexed color image can nearly match the original.

But this creates a heavy dependence between the image pixels and its adaptive palette. Assuming a limited 8-bit depth graphic display, it is necessary to load a given image's adaptive palette into the color hardware registers prior to loading the image surface itself into the frame buffer. To display different images with different adaptive palettes, they must to be loaded one by one, as in a slideshow. Here are samples of four different indexed color images with color patches to show their respective (and largely incompatible) adaptive palettes:

An application can, in turn, show many different image thumbnails in a mosaic on screen. It is obvious that the program cannot load all the adaptive palettes of every displayed image thumbnail at the same time in the hardware color registers. A solution is to use a unique, common master palette or universal palette, which can be used to display with reasonable accuracy any kind of image.

This is done by selecting colors in such way that the master palette comprises a full RGB color space "in miniature", limiting the possible levels that the red, green and blue components may have. This kind of arrangement is sometimes referred as a uniform palette. The normal human eye has sensibility to the three primary colors in different degrees: the more to the green, the less to the blue. So RGB arrangements can take advantage of this by assigning more levels for the green component and less to the blue.

A master palette built this way can be filled with up to 8R×8G×4B = 256 colors, but this does not leave space in the palette for reserved colors, color indices that the program could use for special purposes. It is more general to use only 6R×6G×6B = 216 (as in the Web colors case), 6R×8G×5B = 240 or 6R×7G×6B = 252, which leave room for some reserved colors.

Then, when loading the mosaic of image thumbnails (or other heterogeneous images), the program simply maps every original indexed color pixel to its most approximated in the master palette (after dumping this into the hardware color registers), and writes the result in the video buffer. Here is a sample of a simple mosaic of the four image thumbnails using a master palette of 240 RGB arranged colors plus 16 additional intermediate shades of gray; all images are put together without a significant loss of color accuracy:

Read more about this topic:  Palette (computing)