RGBA32

Index:
ppm2rgba
rgba2ppm
rgbaadd
rgbaaddB
rgbaautocrop
rgbadither
rgbafade
rgbamerge
rgbamergeB
rgbaquant
rgbascale
rgbascaleB
rgbascaleF
rgbasub
rgbasubB
rgbatrans

trouble-
shooting

the RGBA32 manual and style guide:

rgbaquant
rgbadither

Command line:

rgbaquant [input_file] colors [ split1 [ split2 ] ]
rgbadither [input_file] colors [ split1 [ split2 ] ]

Usage:

Rgbaquant and rgbadither reduce the number of colors used in a 32 bit RGBA image. They are intended to be as good as XV and ppmquant at large colormaps (256 colors or greater), but offermuch better performance for small colormaps (2 to 64 colors). Rgbaquant sets each pixel to the closest color in the resulting colormap and rgbadither dithers the image to reduce overall 'color' error.

Rgbaquant and rgbadither can take input either from stdin or from a file specified on the command line. If a filename appears on the command line, stdin will not be checked for input. Filenames must appear before numeric arguments. The number of colors to appear in the new colormap is the only required argument.

The second and third optional numeric arguments are intended to influence the heuristics used to choose the new colormap. Rgbaquant and rgbadither use three seperate algorithms in concert to choose a new colormap. The first two are based on IJG code and break an RGB colorcube space into smaller and smaller rectangular areas; the first algorithm breaks in half each area with the largest color population and the second breaks in half by area volume. The first 'split' argument assigns how many colors will be chosen by the first algorithm before the second takes over.

The third algorithm used is the 'color diversity' algorithm developed by John Bradley and used (in a modified form) by XV. The idea here is to always choose the color from the original image farthest from each entry in the already chosen portion of the new colormap. The second 'split' argument specifies how many colors the IJG algorithms may choose before the third 'diversity' algorithm takes over. The split arguments are optional; rgbaquant and rgbadither will choose defaults that are appropriate for most images.

Note that 'transparent' colors exist as if they were opaque as far as rgbaquant and rgbadither are concerned. Output is directed to stdout and errors to stderr.

Examples:

Note that the images as shown in the browser are GIFs; the actual rgba output is converted to GIF such that the browser can display it. Warning; Web browsers running on less than a 16 bit display (less than 65K colors) will almost certainly substitute colors wildly and/or dither the below images. This will degrade the image quality considerably.

256 colors
ppmquant 256 rgbaquant 256 rgbadither 256

24 colors
ppmquant 24 rgbaquant 24 rgbadither 24

7 colors
ppmquant 7 rgbaquant 7 rgbadither 7

2 colors
ppmquant 2 rgbaquant 2 rgbadither 2

32 colors using different 'split' options
rgbaquant 32 (equivalent to rgbaquant 32 7 19)
rgbaquant 32 0 0 rgbaquant 32 0 32 rgbaquant 32 32 32

Bugs:

In the interest of simple command-line parsing, all arguments that begin with a digit, decimal point or unary minus are considered to be numeric arguments (not filenames). Therefore, the input file cannot begin with any of these else it would be mistakenly taken as the first numeric argument.


These pages are copyright (C) 1994-1997 Xiphophorus. All rights reserved.