Convert a 24bit RGB image to 8bit paletted
rgb2pct.py [-n colors] [-of format] source_file dest_file
This utility will compute an optimal pseudo-color table for a given RGB image using a median cut algorithm on a downsampled RGB histogram. Then it converts the image into a pseudo-colored image using the color table. This conversion utilizes Floyd-Steinberg dithering (error diffusion) to maximize output image visual quality.
NOTE: rgb2pct.py is a Python script, and will only work if GDAL was built with Python support.