|
This program is part of
Netpbm(1).
pnmcolormap reads a PNM or PAM image as input, chooses
ncolors colors to best represent the image and writes a PNM
color map defining them as output. A PAM image may actually contain
tuples of any kind, but pnmcolormap's concept of the tuple values
that best represent the ones present in the image may not make sense if
the tuple type isn't RGB or GRAYSCALE. The design of the program, and
the rest of this manual, assumes the tuples represent colors.
You can use this map as input to pnmremap on the same input
image to quantize the colors in that image, I.e. produce a similar
image with fewer colors. pnmquant does both the pnmcolormap
and pnmremap steps for you.
A PNM colormap is a PNM image of any dimensions that contains at
least one pixel of each color in the set of colors it represents. The
ones pnmcolormap generates have exactly one pixel of each color,
except where padding is necessary with the -square option.
The quantization method is Heckbert's 'median cut'.
See
QUANTIZATION METHOD
.
The output image is of the same format (PBM, PGM, PPM, PAM) as the
input image. Note that a colormap of a PBM image is not very
interesting.
The colormap generally has the same maxval as the input image, but
pnmcolormap may reduce it if there are too many colors in the
input, as part of its quantization algorithm.
pnmcolormap works on a multi-image input stream. In that
case, it produces one colormap that applies to all of the colors in
all of the input images. All the images must have the same format,
depth, and maxval (but may have different height and width). This is
useful if you need to quantize a bunch of images that will form a
movie or otherwise be used together -- you generally want them all to
draw from the same palette, whereas computing a colormap separately
from each image would make the same color in two images map to
different colors. Before Netpbm 10.31 (December 2005), pnmcolormap
ignored any image after the first.
If you want to create a colormap without basing it on the colors in
an input image, pamseq, ppmmake, and pnmcat can
be useful.
|