Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

rgb2pct(1) [debian man page]

rgb2pct(1)						      General Commands Manual							rgb2pct(1)

NAME
rgb2pct - 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. The palette_file must be a raster file in a GDAL supported format with a palette. -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. EXAMPLE
If it is desired to hand create the palette, likely the simpliest text format is the GDAL VRT format. In the following example a VRT was created in a text editor with a small 4 color palette with the RGBA colors 238/238/238/255, 237/237/237/255, 236/236/236/255 and 229/229/229/255. % rgb2pct.py -pct palette.vrt rgb.tif pseudo-colored.tif % more < palette.vrt <VRTDataset rasterXSize="226" rasterYSize="271"> <VRTRasterBand dataType="Byte" band="1"> <ColorInterp>Palette</ColorInterp> <ColorTable> <Entry c1="238" c2="238" c3="238" c4="255"/> <Entry c1="237" c2="237" c3="237" c4="255"/> <Entry c1="236" c2="236" c3="236" c4="255"/> <Entry c1="229" c2="229" c3="229" c4="255"/> </ColorTable> </VRTRasterBand> </VRTDataset> AUTHOR
Frank Warmerdam warmerdam@pobox.com GDAL
Tue Sep 18 2012 rgb2pct(1)

Check Out this Related Man Page

ppmquant(1)						      General Commands Manual						       ppmquant(1)

NAME
ppmquant - quantize the colors in a portable pixmap down to a specified number SYNOPSIS
ppmquant [-floyd|-fs] ncolors [ppmfile] ppmquant [-floyd|-fs] [-nofloyd|-nofs] -mapfile mapfile [ppmfile] All options can be abbreviated to their shortest unique prefix. You may use two hyphens instead of one to designate an option. You may use either white space or equals signs between an option name and its value. DESCRIPTION
pnmquant is a newer, more general program that is backward compatible with ppmquant. ppmquant may be faster, though. Reads a PPM image as input. Chooses ncolors colors to best represent the image, maps the existing colors to the new ones, and writes a PPM image as output. The quantization method is Heckbert's "median cut". Alternately, you can skip the color-choosing step by specifying your own set of colors with the -mapfile option. The mapfile is just a ppm file; it can be any shape, all that matters is the colors in it. For instance, to quantize down to the 8-color IBM TTL color set, you might use: P3 8 1 255 0 0 0 255 0 0 0 255 0 0 0 255 255 255 0 255 0 255 0 255 255 255 255 255 If you want to quantize one image to use the colors in another one, just use the second one as the mapfile. You don't have to reduce it down to only one pixel of each color, just use it as is. If you use a mapfile, the output image has the same maxval as the mapfile. Otherwise, the output maxval is the same as the input maxval, or less in some cases where the quantization process reduces the necessary resolution. The -floyd/-fs option enables a Floyd-Steinberg error diffusion step. Floyd-Steinberg gives vastly better results on images where the unmodified quantization has banding or other artifacts, especially when going to a small number of colors such as the above IBM set. How- ever, it does take substantially more CPU time, so the default is off. -nofloyd/-nofs means not to use the Floyd-Steinberg error diffusion. This is the default. REFERENCES
"Color Image Quantization for Frame Buffer Display" by Paul Heckbert, SIGGRAPH '82 Proceedings, page 297. SEE ALSO
pnmquant(1), ppmquantall(1), pnmdepth(1), ppmdither(1), ppm(5) AUTHOR
Copyright (C) 1989, 1991 by Jef Poskanzer. 12 January 1991 ppmquant(1)
Man Page