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
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML><HEAD><TITLE>Ppmchange User Manual</TITLE></HEAD>
<BODY>
<H1>ppmchange</H1>
Updated: December 2016
<BR>
<A HREF="#index">Table Of Contents</A>
<H2>NAME</H2>
ppmchange - change all pixels of one color to another in a PPM image
<H2 id="synopsis">SYNOPSIS</H2>
<B>ppmchange</B>
[<B>-closeness=</B><I>closeness_percent</I>]
[<B>-remainder=</B><I>remainder_color</I>]
[<B>-closeok</b>]
[<I>oldcolor newcolor</I>] ...
[<I>ppmfile</I>]
<H2 id="examples">EXAMPLES</H2>
<PRE>
<b>ppmchange red blue redimage.ppm >blueimage.ppm</b>
<b>ppmchange red red -remainder=black myimage.ppm >redblack.ppm</b>
<b>ppmchange -closeness=10 white white black black</b>
</PRE>
<H2 id="description">DESCRIPTION</H2>
<p>This program is part of <a href="index.html">Netpbm</a>.
<p><b>ppmchange</b> reads a PPM image as input and changes all pixels of
color <I>oldcolor</I> to color <I>newcolor</I>.
You may specify up to 256 oldcolor/newcolor pairs on the command line.
<B>ppmchange</B> leaves all colors not mentioned unchanged, unless you
specify the <B>-remainder</B> option, in which case they are all
changed to the single specified color.
<P>You can specify that colors similar, but not identical, to the ones
you specify get replaced by specifying a "closeness" factor.
<P>Specify the colors as described for the <a
href="libppm.html#colorname">argument of the <b>ppm_parsecolor()</b>
library routine</a>.
<P>If a pixel matches two different <I>oldcolor</I>s, <B>ppmchange</B>
replaces it with the <I>newcolor</I> of the leftmost specified one.
<p>The maxval of the output image is the same as that of the input
image. If a <i>newcolor</i> you specify cannot be exactly represented
in that maxval, <b>ppmchange</b> assumes a color that is as close as
possible to what you specified but can be represented with your
maxval. Unless you specify the <b>-closeok</b> option,
<b>ppmchange</b> issues a warning that it is using an approximation.
<p>A common way that you can have this maxval problem, where the color
you specify cannot be represented with your maxval, is that your input
is a PBM (black and white) image that you are colorizing. The maxval
in this case is 1, which severely limits the colors to which you can
change. To avoid this problem, use <b>pamdepth</b> to make the maxval
of your input something consistent with your colors. 255 is usually a
good choice.
<p>Before Netpbm 10.22 (April 2004), <b>ppmchange</b> always behaved as
if the user specified <b>-closeok</b> and there was no <b>-closeok</b>
option.
<H2 id="options">OPTIONS</H2>
<DL COMPACT>
<DT><B>-closeness </B><I>closeness_percent</I>
<DD><I>closeness</I> is a percentage indicating how close to the color you
specified a pixel must be to get replaced. By default, it is 0, which means
the pixel must be the exact color you specified.
<P>A pixel gets replaced if the distance in color between it and the
color you specified is less than or equal to <I>closeness</I> per cent
of the maxval.
<P>The "distance" in color is defined as the Cartesian sum of the
individual differences in red, green, and blue intensities between the
two pixels, normalized so that the difference between black and white
is 100%.
<P>This is probably simpler than what you want most the time. You
probably would like to change colors that have similar chrominance,
regardless of their intensity. So if there's a red barn that is
variously shadowed, you want the entire barn changed. But because the
shadowing significantly changes the color according to
<B>ppmchange</B>'s distance formula, parts of the barn are probably
about as distant in color from other parts of the barn as they are
from green grass next to the barn.
<P>Maybe <B>ppmchange</B> will be enhanced some day to do chrominance
analysis.
<p>This option was new in Netpbm 9.8 (September 2000).
<dt><b>-closeok</b>
<dd>This option affects how <b>ppmchange</b> interprets a color you
specify in the arguments. When you specify this option, <b>ppmchange</b>
may use a color close to, but not the same as what you specify. See
<a href="#description">the description section</a> for details.
<p>This option was new in Netpbm 10.22 (April 2004). Before that,
<b>ppmchange</b> always behaved as if you specified this option.
<DT><B>-remainder </B><I>color</I>
<DD><B>ppmchange</B> changes all pixels which are not of a color for
which you specify an explicit replacement color on the command line to
color <I>color</I>.
<P>An example application of this is
<pre>
<B>ppmchange -remainder=black red red</B>
</pre>
to lift only the red portions from an image, or
<pre>
<B>ppmchange -remainder=black red white | ppmtopgm</B>
</pre>
to create a mask file for the red portions of the image.
</DL>
<H2 id="seealso">SEE ALSO</H2>
<B><A HREF="pgmtoppm.html">pgmtoppm</A></B>,
<B><A HREF="ppmcolormask.html">ppmcolormask</A></B>,
<B><A HREF="ppm.html">ppm</A></B>
<H2 id="author">AUTHOR</H2>
Wilson H. Bent. Jr. (<A HREF="mailto:whb@usc.edu">whb@usc.edu</A>)
with modifications by Alberto Accomazzi (<A
HREF="mailto:alberto@cfa.harvard.edu">alberto@cfa.harvard.edu</A>)
<HR>
<A NAME="index"> </A>
<H2>Table Of Contents</H2>
<UL>
<LI><A HREF="#synopsis">SYNOPSIS</A>
<LI><A HREF="#examples">EXAMPLES</A>
<LI><A HREF="#description">DESCRIPTION</A>
<LI><A HREF="#options">OPTIONS</A>
<LI><A HREF="#seealos">SEE ALSO</A>
<LI><A HREF="#author">AUTHOR</A>
</UL>
</BODY>
</HTML>
|