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
subdirectory of the IDL distribution.
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
contains pixel values from 0 to M,
will be an M+1 element vector containing the mapping from the old values to the new.
contains the new color index of old pixel index
To reduce the number of colors and display an image with the original color tables R, G, B enter the commands:
REDUCE_COLORS, image, v
TVLCT, R[V], G[V], B[V]