1rgb2pct(1)                  General Commands Manual                 rgb2pct(1)
2
3
4

NAME

6       rgb2pctConvert a 24bit RGB image to 8bit paletted.
7

SYNOPSIS

9       rgb2pct.py [-n colors | -pct palette_file] [-of format] source_file dest_file
10

DESCRIPTION

12       This utility will compute an optimal pseudo-color table for a given RGB
13       image using a median cut algorithm on a downsampled RGB histogram. Then
14       it converts the image into a pseudo-colored image using the color
15       table. This conversion utilizes Floyd-Steinberg dithering (error
16       diffusion) to maximize output image visual quality.
17
18       -n colors:
19           Select the number of colors in the generated color table. Defaults
20           to 256. Must be between 2 and 256.
21
22       -pct palette_file:
23           Extract the color table from palette_file instead of computing it.
24           Can be used to have a consistent color table for multiple files.
25           The palette_file must be a raster file in a GDAL supported format
26           with a palette.
27
28       -of format:
29           Select the output format. Starting with GDAL 2.3, if not specified,
30           the format is guessed from the extension (previously was GTiff).
31           Use the short format name. Only output formats supporting pseudo-
32           color tables should be used.
33
34       source_file:
35           The input RGB file.
36
37       dest_file:
38           The output pseudo-colored file that will be created.
39
40       NOTE: rgb2pct.py is a Python script, and will only work if GDAL was
41       built with Python support.
42

EXAMPLE

44       If it is desired to hand create the palette, likely the simplest text
45       format is the GDAL VRT format. In the following example a VRT was
46       created in a text editor with a small 4 color palette with the RGBA
47       colors 238/238/238/255, 237/237/237/255, 236/236/236/255 and
48       229/229/229/255.
49
50       % rgb2pct.py -pct palette.vrt rgb.tif pseudo-colored.tif
51       % more < palette.vrt
52       <VRTDataset rasterXSize="226" rasterYSize="271">
53         <VRTRasterBand dataType="Byte" band="1">
54           <ColorInterp>Palette</ColorInterp>
55           <ColorTable>
56             <Entry c1="238" c2="238" c3="238" c4="255"/>
57             <Entry c1="237" c2="237" c3="237" c4="255"/>
58             <Entry c1="236" c2="236" c3="236" c4="255"/>
59             <Entry c1="229" c2="229" c3="229" c4="255"/>
60           </ColorTable>
61         </VRTRasterBand>
62       </VRTDataset>
63

AUTHOR

65       Frank Warmerdam warmerdam@pobox.com
66
67
68
69GDAL                            Tue Mar 3 2020                      rgb2pct(1)
Impressum