GDAL: rgb2pct.py

# rgb2pct.py

Convert a 24bit RGB image to 8bit paletted

## SYNOPSIS

    rgb2pct.py [-n colors] [-of format] source_file dest_file

## DESCRIPTION

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.

-n colors:
  Select the number of colors in the generated color table. Defaults to 256. Must be between 2 and 256.
-of format:
  Format to generated (defaults to GeoTIFF). Same semantics as the -of flag for gdal_translate. Only output formats supporting pseudocolor tables should be used.
source_file:
  The input RGB file.
dest_file:
  The output pseudo-colored file that will be created.

NOTE: rgb2pct.py is a Python script, and will only work if GDAL was built with Python support.

Generated for GDAL by 1.5.9.