The REDUCE_COLORS procedure reduces the number of colors used in an image by eliminating pixel values without members.

The pixel distribution histogram is obtained and the WHERE function is used to find bins with non-zero values. Next, a lookup table is made where table(old_pixel_value) contains new_pixel_value, and then applied to the image.

This routine is written in the IDL language. Its source code can be found in the file in the lib subdirectory of the IDL distribution.

Calling Sequence:

REDUCE_COLORS, Image, Values



On input, a variable that contains the original image array. On output, this variable contains the color-reduced image array, writing over the original.


A named variable that, on output, contains a vector of non-zero pixel values. If Image contains pixel values from 0 to M, Values will be an M+1 element vector containing the mapping from the old values to the new. Values[i] contains the new color index of old pixel index i .


To reduce the number of colors and display an image with the original color tables R, G, B enter the commands:


TVLCT, R[V], G[V], B[V]

See Also