1Pgmtoppm User Manual(0) Pgmtoppm User Manual(0)
2
3
4
6 pgmtoppm - colorize a PGM (grayscale) image into a PPM (color) image
7
8
10 pgmtoppm [-black=colorspec1] [-white=colorspec2]
11 [pgmfile]
12
13 pgmtoppm -map=filename [pgmfile]
14
15 pgmtoppm colorspec [pgmfile] pgmtoppm colorspec1-colorspec2 [pgmfile]
16
17 Minimum unique abbreviation of option is acceptable. You may use dou‐
18 ble hyphens instead of single hyphen to denote options. You may use
19 white space in place of the equals sign to separate an option name from
20 its value.
21
22
24 This program is part of Netpbm(1).
25
26 pgmtoppm reads a PGM as input and produces a PPM file as output with a
27 specific color assigned to each gray value in the input.
28
29 You can specify the color in the output to which black in the input
30 maps,
31 and the color to which white maps. All the gray values in between
32 map
33 linearly (across a three dimensional space) to colors between the
34 black and
35 white colors you specify.
36
37 Use the -black and -white options for this. For historical
38 reasons, you can alternatively use a non-option argument to specify
39 the
40 colors. If you do that, pgmtoppm interprets the color argument
41 like this: if the argument takes the form black-white,
42 it has the effect of -black=black -white=white
43 If instead there is no hyphen in the color argument, it has the ef‐
44 fect of
45 -white=color_argument.
46
47 Because of the historical syntax, it is not possible to let both
48 -black and -white default (but you shouldn't want to --
49 see below for advice on making such a null conversion).
50
51
52 You can alternatively specify an entire colormap with the -map option.
53
54
55 A more direct way to specify a particular color to replace each partic‐
56 ular gray level is to use pamlookup. You make an index file that ex‐
57 plicitly associates a color with each possible gray level.
58
59 If all you want to do is convert PGM to PPM, keeping the same gray pix‐
60 els,
61 you may not need to. All Netpbm programs that expect PPM input also
62 recognize PGM. And if you must have a PPM file, use ppmtoppm
63 instead. It is more efficient and easier to use.
64
65
66
68 In addition to the options common to all programs based on libnetpbm
69 (most notably -quiet, see
70 Common Options ⟨index.html#commonoptions⟩ ), pgmtoppm recognizes the
71 following command line options:
72
73
74
75
76 -black=colorspec
77 The program maps black pixels in the input to this color in the
78 output. The default is black.
79
80 Specify the color (color) as described for the argument of the
81 pnm_parsecolor() library routine
82 ⟨libnetpbm_image.html#colorname⟩ .
83
84 You cannot specify this together with -map.
85
86 This option was new in Netpbm 10.97 (December 2021). Before
87 that,
88 use the color argument.
89
90
91 -white=colorspec
92 The program maps white pixels in the input to this color in the
93 output. The default is white.
94
95 Specify the color (color) as described for the argument of the
96 pnm_parsecolor() library routine
97 ⟨libnetpbm_image.html#colorname⟩ .
98
99 You cannot specify this together with -map.
100
101 This option was new in Netpbm 10.97 (December 2021). Before
102 that,
103 use the color argument.
104
105
106 -map=filename
107 This option specifies a complete mapping of gray values in the
108 input to
109 color values in the output. The map file (named filename)
110 is just
111 a ppm file; it can be any shape, all that matters is the
112 colors in
113 it and their order. In this case, black gets mapped into
114 the first color
115 in the map file, and white gets mapped to the last and gray
116 values in
117 between are mapped linearly onto the sequence of colors in
118 between. The
119 maxval of the output image is the maxval of the map image.
120
121
122
123
124
126 When you don't use -map, the "maxval," or depth, of the output image is
127 the same as that of the input image. The maxval affects the color res‐
128 olution, which may cause quantization errors you don't anticipate in
129 your output. For example, you have a simple black and white image as a
130 PGM with maxval 1. Run this image through pgmtoppm 0f/00/00 to try to
131 make the image black and faint red. Because the output image will also
132 have maxval 1, there is no such thing as faint red. It has to be ei‐
133 ther full-on red or black. pgmtoppm rounds the color 0f/00/00 down to
134 black, and you get an output image that is nothing but black.
135
136 The fix is easy: Pass the input through pamdepth on the way into pgm‐
137 toppm to increase its depth to something that would give you the reso‐
138 lution you need to get your desired color. In this case, pamdepth 16
139 would do it. Or spare yourself the unnecessary thinking and just say
140 pamdepth 255.
141
142 PBM input is a special case. While you might think this would be
143 equivalent to a PGM with maxval 1 since only two gray levels are neces‐
144 sary to represent a PBM image, pgmtoppm, like all Netpbm programs, in
145 fact treats it as a maxval of 255.
146
147
149 ppmtoppm(1), pamdepth(1), rgb3toppm(1), ppmtopgm(1), ppmtorgb3(1),
150 ppm(1), pgm(1)
151
152
154 Copyright (C) 1991 by Jef Poskanzer.
155
157 This manual page was generated by the Netpbm tool 'makeman' from HTML
158 source. The master documentation is at
159
160 http://netpbm.sourceforge.net/doc/pgmtoppm.html
161
162netpbm documentation 02 October 2021 Pgmtoppm User Manual(0)