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

NAME

6       pnmremap - replace colors in a PNM image with colors from another set
7
8

SYNOPSIS

10       pnmremap
11
12       -mapfile=palettefile
13
14       [-floyd|-fs|-nfloyd|-nofs]
15
16       [-norandom]
17
18       [-firstisdefault]
19
20       [-verbose]
21
22       [-missingcolor=color]
23
24       [pnmfile]
25
26       All  options  can  be abbreviated to their shortest unique prefix.  You
27       may use two hyphens instead of one to designate an option.  You may use
28       either  white  space  or  an equals sign between an option name and its
29       value.
30
31

DESCRIPTION

33       This program is part of Netpbm(1).
34
35       pnmremap replaces the colors in an input image with those from  a  pal‐
36       ette  you  specify.   Where colors in the input are present in the pal‐
37       ette, they just stay the same in the output.  But where the input  con‐
38       tains  a  color  that  is  not in the palette, pnmremap gives you these
39       choices:
40
41
42
43       ·      Choose the closest color from the palette.
44
45
46       ·      Choose the first color from the palette.
47
48
49       ·      Use a color specified by a command option (-missing).
50
51
52       ·      Dither.  This means rather than mapping pixel by pixel, pnmremap
53              uses  colors from the palette to try to make multi-pixel regions
54              of the output have the same average  color  as  the  input  (for
55              another kind of dithering, see ppmdither).
56
57
58
59       Two  reasons  to use this program are: 1) you want to reduce the number
60       of colors in the input image; and 2) you need  to  feed  the  image  to
61       something that can handle only certain colors.
62
63       To reduce colors, you can generate the palette with pnmcolormap.
64
65       By  default, pnmremap maps an input color that is not in the palette to
66       the closest color that is in  the  palette.   Closest  means  with  the
67       smallest  cartesian  distance  in the red, green, blue brightness space
68       (smallest sum of the squares of the differences in red, green, and blue
69       ITU-R Recommedation BT.709 gamma-adjusted intensities).
70
71       You  can instead specify a single default color for pnmremap to use for
72       any color in the input image that is  not  in  the  palette.   Use  the
73       -missing option for this.
74
75       You  can  also specify that the first color in the palette image is the
76       default.  Use the -firstisdefault option for this.
77
78       The palette is simply a PNM image.  The colors of  the  pixels  in  the
79       image  are  the  colors in the palette.  Where the pixels appear in the
80       image, and the dimensions of the image, are irrelevant.  Multiple  pix‐
81       els  of the same color are fine.  However, a palette image is typically
82       a single row with one pixel per color.
83
84       If you specify -missing, the color you so specify is in the palette  in
85       addition to whatever is in the palette image.
86
87       For  historical  reasons,  Netpbm  sometimes  calls the palette a 'col‐
88       ormap.' But it doesn't really map anything.  pnmremap creates  its  own
89       map, based on the palette, to map colors from the input image to output
90       colors.
91
92
93   Palette/Image Type Mismatch
94       In the simple case, the palette image is of the same depth  (number  of
95       planes,  i.e.  number of components in each tuple (pixel)) as the input
96       image and pnmremap just does a straightforward search  of  the  palette
97       for  each  input tuple (pixel).  In fact, pnmremap doesn't even care if
98       the image is a visual image.
99
100       But what about when the depths differ?  In that case, pnmremap converts
101       the  input image (in its own memory) to match the palette and then pro‐
102       ceeds as above.
103
104       There are only two such cases in which pnmremap knows  how  to  do  the
105       conversion:  when one of them is tuple type RGB, depth 3, and the other
106       is tuple type GRAYSCALE or BLACKANDWHITE, depth 1; and vice versa.
107
108       In any other case, pnmremap issues and error message and fails.
109
110       Note that as long as your input and palette  images  are  PNM,  they'll
111       always  fall  into  one  of  the cases pnmremap can handle.  There's an
112       issue only if you're using some exotic PAM image.
113
114       Before Netpbm 10.27 (March 2005), pnmremap could not handle the case of
115       a  palette  of  greater depth than the input image.  (It would issue an
116       error message and fail in that case).
117
118       In any case, the output image has the same tuple type and depth as  the
119       palette image.
120
121
122   Multiple Image Stream
123       pnmremap  handles  a  multiple image input stream, producing a multiple
124       image output stream.  The input images need not be similar in any way.
125
126       Before Netpbm 10.30 (October 2005), pnmremap ignored  any  image  after
127       the first.
128
129
130
131   Examples
132       pnmcolormap testimg.ppm 256 >palette.ppm
133
134       pnmremap -map=palette.ppm testimg.ppm >reduced_testimg.ppm
135
136       To  limit  colors  to  a certain set, a typical example is to create an
137       image for posting on the World Wide Web, where different browsers  know
138       different  colors.   But all browsers are supposed to know the 216 'web
139       safe' colors which are essentially all the colors you can represent  in
140       a PPM image with a maxval of 5.  So you can do this:
141
142       pamseq 3 5 >websafe.pam
143
144       pnmremap -map=websafe.pam testimg.ppm >websafe_testimg.ppm
145
146       Another  useful palette is one for the 8 color IBM TTL color set, which
147       you can create with
148       pamseq 3 1 >ibmttl.pam
149
150       If you want to quantize one image to use the  colors  in  another  one,
151       just  use  the  second one as the palette.  You don't have to reduce it
152       down to only one pixel of each color, just use it as is.
153
154       The output image has the same type and maxval as the palette image.
155
156

PARAMETERS

158       There is one parameter, which is required: The  file  specification  of
159       the input PNM file.
160
161
162

OPTIONS

164       -mapfile=palettefilename
165              This names the file that contains the palette image.
166
167              This option is mandatory.
168
169
170       -floyd
171
172       -fs
173
174       -nofloyd
175
176       -nofs  These  options  determine  whether  Floyd-Steinberg dithering is
177              done.  Without Floyd-Steinberg, the selection of output color of
178              a  pixel  is  based on the color of only the corresponding input
179              pixel.  With Floyd-Steinberg, multiple input pixels are  consid‐
180              ered so that the average color of an area tends to stay more the
181              same than without Floyd-Steinberg.  For example, if you  map  an
182              image  with  a black, gray, gray, and white pixel adjacent, to a
183              palette that contains only black and white, it might  result  in
184              an output of black, black, white, white.  Pixel-by-pixel mapping
185              would instead map both the gray pixels to the same color.
186
187              Floyd-Steinberg gives vastly  better  results  on  images  where
188              unmodified  quantization  has  banding or other artifacts, espe‐
189              cially when going to a small number of colors such as the  above
190              IBM set.  However, it does take substantially more CPU time.
191
192              -fs is a synomym for -floyd.  -nofs is a synonym for -nofloyd.
193
194              The default is -nofloyd.
195
196
197
198       -norandom
199              This  option  affects  a detail of the Floyd-Steinberg dithering
200              process.  It has no effect if you aren't  doing  Floyd-Steinberg
201              dithering.
202
203              By default, pnmremap initializes the error propagation accumula‐
204              tor to random values to avoid the appearance  of  unwanted  pat‐
205              terns.   This  is  an  extension of the original Floyd-Steinberg
206              algorithm.
207
208              A drawback of this is that the same pnmremap on the  same  input
209              produces  slightly different output every time, which makes com‐
210              parison difficult.
211
212              With -norandom, pnmremap initializes the error  accumulators  to
213              zero and the output is completely predictable.
214
215              -norandom was new in Netpbm 10.39 (June 2007).
216
217
218
219       -firstisdefault
220              This  tells  pnmremap  to map any input color that is not in the
221              palette to the first color in the  palette  (the  color  of  the
222              pixel in the top left corner of the palette image)
223
224              See DESCRIPTION ⟨#description⟩ .
225
226              If  you  specify  -firstisdefault, the maxval of your input must
227              match the maxval of your palette image.
228
229
230       -missingcolor=color
231              This specifies the default color for pnmremap to map to a  color
232              in  the input image that isn't in the palette.  color may or may
233              not be in the palette image; it is part of the  palette  regard‐
234              less.
235
236              If  you  specify  -missingcolor,  the  maxval of your input must
237              match the maxval of your palette image.
238
239
240       -verbose
241              Display helpful messages about the mapping process.
242
243
244
245
246

SEE ALSO

248       pnmcolormap(1), pamseq(1),  pnmquant(1),  ppmquantall(1),  pamdepth(1),
249       ppmdither(1), ppmquant(1), ppm(1)
250
251

AUTHOR

253       Copyright (C) 1989, 1991 by Jef Poskanzer.
254
255
256
257netpbm documentation            01 January 2002        Pnmremap User Manual(0)
Impressum