1Pnmcolormap User Manual(0)                          Pnmcolormap User Manual(0)
2
3
4

NAME

6       pnmcolormap - create quantization color map for a Netpbm image
7
8

SYNOPSIS

10       pnmcolormap
11
12       [-center|-meancolor|-meanpixel]
13
14       [-spreadbrightness|-spreadluminosity]
15
16       [-splitpixelct|-splitcolorct|-splitspread]
17
18       [-sort]
19
20       [-square]
21
22       ncolors|all
23
24       [pnmfile]
25
26

DESCRIPTION

28       This program is part of Netpbm(1).
29
30       pnmcolormap  reads  a PNM or PAM image as input, chooses ncolors colors
31       to best represent the image and writes a PNM color map defining them as
32       output.   A PAM image may actually contain tuples of any kind, but pnm‐
33       colormap's concept of the tuple values that  best  represent  the  ones
34       present  in the image may not make sense if the tuple type isn't RGB or
35       GRAYSCALE.  The design of the program, and the  rest  of  this  manual,
36       assumes the tuples represent colors.
37
38       You  can  use  this map as input to pnmremap on the same input image to
39       quantize the colors in that image, I.e. produce a  similar  image  with
40       fewer  colors.   pnmquant  does both the pnmcolormap and pnmremap steps
41       for you.
42
43       A PNM colormap is a PNM image of any dimensions that contains at  least
44       one  pixel  of each color in the set of colors it represents.  The ones
45       pnmcolormap generates have exactly one  pixel  of  each  color,  except
46       where padding is necessary with the -square option.
47
48       The  quantization  method is Heckbert's "median cut".  See QUANTIZATION
49       METHOD ⟨#quant⟩ .
50
51       The output image is of the same format (PBM,  PGM,  PPM,  PAM)  as  the
52       input image.  Note that a colormap of a PBM image is not very interest‐
53       ing.
54
55       The colormap generally has the same maxval as the input image, but pnm‐
56       colormap  may  reduce  it if there are too many colors in the input, as
57       part of its quantization algorithm.
58
59       pnmcolormap works on a multi-image input stream.  In that case, it pro‐
60       duces  one  colormap  that  applies  to all of the colors in all of the
61       input images.  All the images must have the  same  format,  depth,  and
62       maxval  (but  may  have different height and width).  This is useful if
63       you need to quantize a bunch of images that will form a movie or other‐
64       wise  be  used together -- you generally want them all to draw from the
65       same palette, whereas computing a colormap separately from  each  image
66       would  make  the  same  color  in  two  images map to different colors.
67       Before Netpbm 10.31 (December  2005),  pnmcolormap  ignored  any  image
68       after the first.
69
70       If  you want to create a colormap without basing it on the colors in an
71       input image, pamseq, ppmmake, and pnmcat can be useful.
72
73

PARAMETERS

75       The single parameter, which is required, is the number  of  colors  you
76       want  in the output colormap.  pnmcolormap may produce a color map with
77       slightly fewer colors than that.  You may specify all to get a colormap
78       of  every color in the input image (no quantization).  When you specify
79       all, the function is essentially the same  as  that  of  ppmhist  -map.
80       ppmhist is much older.
81
82
83

OPTIONS

85       In  addition  to  the options common to all programs based on libnetpbm
86       (most notably -quiet, see
87        Common Options ⟨index.html#commonoptions⟩  ),  pnmcolormap  recognizes
88       the following command line options:
89
90       All  options  can  be abbreviated to their shortest unique prefix.  You
91       may use two hyphens instead of one to designate an option.  You may use
92       either  white  space  or  an equals sign between an option name and its
93       value.
94
95
96
97       -sort  This option causes the output colormap to be sorted by  the  red
98              component  intensity, then the green, then the blue in ascending
99              order.  This is an insertion sort, so it is  not  very  fast  on
100              large  colormaps.   Sorting  is  useful because it allows you to
101              compare two sets of colors.
102
103
104       -square
105              By default, pnmcolormap produces as the color map  a  PPM  image
106              with one row and with one column for each color in the colormap.
107              This option causes pnmcolormap instead to produce  a  PPM  image
108              that  is within one row or column of being square, with the last
109              pixel duplicated as necessary to create a number of pixels which
110              is such an almost-perfect square.
111
112
113       -verbose
114              This  option  causes pnmcolormap to display messages to Standard
115              Error about the quantization..TP -center
116
117
118       -meancolor
119
120
121       -meanpixel
122
123
124       -spreadbrightness
125
126
127       -spreadluminosity
128
129
130       -splitpixelct
131
132
133       -splitcolorct
134
135
136       -splitspread
137              These  options  control   the   quantization   algorithm.    See
138              QUANTIZATION METHOD ⟨#quant⟩ .
139
140
141
142
143

QUANTIZATION METHOD

145       A  quantization  method is a way to choose which colors, being fewer in
146       number than in the input, you want in  the  output.   pnmcolormap  uses
147       Heckbert's "median cut" quantization method.
148
149       This method involves separating all the colors into "boxes," each hold‐
150       ing colors that represent about the same number of pixels.   You  start
151       with  one  box  and split boxes in two until the number of boxes is the
152       same as the number of colors you want in the  output,  and  choose  one
153       color to represent each box.
154
155       There are three ways pnmcolormap can choose the box to split in
156         each step:
157
158
159       ·      Split the box containing the most pixels.  This is the default,
160                    and  you  can  select it explicitly with option -splitpix‐
161              elct.
162
163       ·      Split the box containing the most colors.  This  appears  to  be
164              useful
165                    for academic purposes only.  Select this with option
166                    -splitcolorct.
167
168       ·      Split the box containing the largest color spread.  Select this
169                    with  option  -splitspread.   This  can  produce  a better
170              result for
171                    small details with  colors  not  found  elsewhere  in  the
172              image.
173
174
175       -splitpixelct, splitcolorct, and splitspread were new
176         in Netpbm 10.88 (September 2019).  Before that, pnmcolormap always
177         splits the box containing the most pixels.
178
179
180       When  you split a box, you do it so each sub-box has the same number of
181       pixels (except one sub-box has more if the full box has an odd number),
182       with the 'greatest' pixels in one sub-box and the 'least' pixels in the
183       other.  "Greater," for a particular box, means it is  brighter  in  the
184       color component (red, green, blue) which has the largest spread in that
185       box.  pnmcolormap gives you two ways to define  "largest  spread.":  1)
186       largest  spread of brightness; 2) largest spread of contribution to the
187       luminosity of the color.  E.g. red is weighted  much  more  than  blue.
188       Select  among  these  with  the -spreadbrightness and -spreadluminosity
189       options.  The default is -spreadbrightness.  Where there  are  multiple
190       colors  of the median magnitude, they are distributed arbitrarily among
191       between the subboxes.  This arbitrary distribution  depends  upon  what
192       the system's qsort function does with multiple equal values, so pnmcol‐
193       ormap may produce slightly different results on different systems.
194
195       pnmcolormap provides three ways of choosing a color to represent a box:
196       1)  the center color - the color halfway between the greatest and least
197       colors in the box, using the above definition of "greater"; 2) the mean
198       of the colors (each component averaged separately by brightness) in the
199       box; 3) the mean weighted by the number of pixels of  a  color  in  the
200       image.
201
202       Select  among  these  with  the  -center,  -meancolor,  and  -meanpixel
203       options.  The default is -center.
204
205       Note that in all three methods, there may be colors in the output which
206       do not appear in the input at all.
207
208       Also  note  that  the color chosen to represent the colors in Box A the
209       best may also represent a color in Box B better than the  color  chosen
210       to  represent  the  colors in Box B the best.  This is true for various
211       measures of goodness of representation of one  color  by  another.   In
212       particular,  if  you  use  pnmremap to map the colors in the very image
213       that you used to create the color map to the colors in  that  colormap,
214       the  colors  in  Box B will often map to the color pnmcolormap chose to
215       represent some other box and in fact the  color  pnmcolormap  chose  to
216       represent Box B may not appear in the pnmremap output at all.
217
218
219

REFERENCES

221       "Color  Image  Quantization for Frame Buffer Display" by Paul Heckbert,
222       SIGGRAPH '82 Proceedings, page 297.
223
224

SEE ALSO

226       pnmremap(1), pnmquant(1), ppmquantall(1), pamgetcolor(1),  pamdepth(1),
227       ppmdither(1), pamseq(1), ppmmake(1), pnmcat(1), ppm(1)
228
229

HISTORY

231       Before  Netpbm  10.15  (April 2003), pnmcolormap used a lot more memory
232       for large images because it kept the  entire  input  image  in  memory.
233       Now,  it  processes  it  a row at a time, but because it sometimes must
234       make multiple passes through the image, it first copies the input  into
235       a temporary seekable file if it is not already in a seekable file.
236
237       pnmcolormap first appeared in Netpbm 9.23 (January 2002).  Before that,
238       its function was available only as part of  the  function  of  pnmquant
239       (which  was  derived from the much older ppmquant).  Color quantization
240       really has two main subfunctions, so Netpbm 9.23 split it out into  two
241       separate  programs:  pnmcolormap  and  pnmremap  and  then  Netpbm 9.24
242       replaced pnmquant with a program that simply calls pnmcolormap and pnm‐
243       remap.
244
245

AUTHOR

247       Copyright (C) 1989, 1991 by Jef Poskanzer.
248

DOCUMENT SOURCE

250       This  manual  page was generated by the Netpbm tool 'makeman' from HTML
251       source.  The master documentation is at
252
253              http://netpbm.sourceforge.net/doc/pnmcolormap.html
254
255netpbm documentation           09 February 2019     Pnmcolormap User Manual(0)
Impressum