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