# rgb2pct.py

Convert a 24bit RGB image to 8bit paletted

## SYNOPSIS

    rgb2pct.py [-n colors | -pct palette_file] [-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.
-pct palette_file:
  Extract the color table from palette_file instead of computing it. Can be used to have a consistant color table for multiple files.
-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.7.1.