Image Processing Toolbox User's Guide Previous page   Next Page

Reducing the Number of Colors in an Image

This section describes how to reduce the number of colors in an indexed or RGB image. A discussion is also included about dithering, which is used by the toolbox's color-reduction functions (see below). Dithering is used to increase the apparent number of colors in an image.

The table below summarizes the Image Processing Toolbox functions for color reduction.

Function
Purpose
imapprox
Reduces the number of colors used by an indexed image, enabling you specify the number of colors in the new colormap.
rgb2ind
Converts an RGB image to an indexed image, enabling you to specify the number of colors to store in the new colormap.

On systems with 24-bit color displays, truecolor images can display up to 16,777,216 (i.e., 224) colors. On systems with lower screen bit depths, truecolor images are still displayed reasonably well, because MATLAB automatically uses color approximation and dithering if needed. Color approximation is the process by which the software chooses replacement colors in the event that direct matches cannot be found. The methods of approximation discussed in this chapter are colormap mapping, uniform quantization, and minimum variance quantization -- see Color Approximation.

Indexed images, however, might cause problems if they have a large number of colors. In general, you should limit indexed images to 256 colors for the following reasons:


Previous page  Working with Different Screen Bit Depths Color Approximation Next page

© 1994-2005 The MathWorks, Inc.