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
reduce_colors.pro
in the
lib
subdirectory of the IDL distribution.
To reduce the number of colors and display an image with the original color tables R, G, B enter the commands: