1Ppmchange User Manual(0) Ppmchange User Manual(0)
2
3
4
6 ppmchange - change all pixels of one color to another in a PPM image
7
8
10 ppmchange
11
12 [-closeness=closeness_percent] [-remainder=remainder_color] [-closeok]
13 [oldcolor newcolor] ... [ppmfile]
14
15
17 ppmchange red blue redimage.ppm >blueimage.ppm
18
19 ppmchange red red -remainder=black myimage.ppm >redblack.ppm
20
21 ppmchange -closeness=10 white white black black
22
23
24
26 This program is part of Netpbm(1).
27
28 ppmchange reads a PPM image as input and changes all pixels of color
29 oldcolor to color newcolor.
30
31 You may specify up to 256 oldcolor/newcolor pairs on the command line.
32 ppmchange leaves all colors not mentioned unchanged, unless you specify
33 the -remainder option, in which case they are all changed to the single
34 specified color.
35
36 You can specify that colors similar, but not identical, to the ones you
37 specify get replaced by specifying a "closeness" factor.
38
39 Specify the colors as described for the argument of the
40 pnm_parsecolor() library routine ⟨libnetpbm_image.html#colorname⟩ .
41
42 If a pixel matches two different oldcolors, ppmchange replaces it with
43 the newcolor of the leftmost specified one.
44
45 The maxval of the output image is the same as that of the input image.
46 If a newcolor you specify cannot be exactly represented in that maxval,
47 ppmchange assumes a color that is as close as possible to what you
48 specified but can be represented with your maxval. Unless you specify
49 the -closeok option, ppmchange issues a warning that it is using an
50 approximation.
51
52 A common way that you can have this maxval problem, where the color you
53 specify cannot be represented with your maxval, is that your input is a
54 PBM (black and white) image that you are colorizing. The maxval in
55 this case is 1, which severely limits the colors to which you can
56 change. To avoid this problem, use pamdepth to make the maxval of your
57 input something consistent with your colors. 255 is usually a good
58 choice.
59
60 Before Netpbm 10.22 (April 2004), ppmchange always behaved as if the
61 user specified -closeok, and there was no -closeok option.
62
63
64
66 In addition to the options common to all programs based on libnetpbm
67 (most notably -quiet, see
68 Common Options ⟨index.html#commonoptions⟩ ), ppmchange recognizes the
69 following command line options:
70
71
72
73 -closeness closeness_percent
74 closeness is a percentage indicating how close to the color you
75 specified a pixel must be to get replaced. By default, it is 0,
76 which means the pixel must be the exact color you specified.
77
78 A pixel gets replaced if the distance in color between it and
79 the color you specified is less than or equal to closeness per
80 cent of the maxval.
81
82 The "distance" in color is defined as the Cartesian sum of the
83 individual differences in red, green, and blue intensities
84 between the two pixels, normalized so that the difference
85 between black and white is 100%.
86
87 This is probably simpler than what you want most the time. You
88 probably would like to change colors that have similar chromi‐
89 nance, regardless of their intensity. So if there's a red barn
90 that is variously shadowed, you want the entire barn changed.
91 But because the shadowing significantly changes the color
92 according to ppmchange's distance formula, parts of the barn are
93 probably about as distant in color from other parts of the barn
94 as they are from green grass next to the barn.
95
96 Maybe ppmchange will be enhanced some day to do chrominance
97 analysis.
98
99 This option was new in Netpbm 9.8 (September 2000).
100
101
102 -closeok
103 This option affects how ppmchange interprets a color you specify
104 in the arguments. When you specify this option, ppmchange may
105 use a color close to, but not the same as what you specify. See
106 the description section ⟨#description⟩ for details.
107
108 This option was new in Netpbm 10.22 (April 2004). Before that,
109 ppmchange always behaved as if you specified this option.
110
111
112 -remainder color
113 ppmchange changes all pixels which are not of a color for which
114 you specify an explicit replacement color on the command line to
115 color color.
116
117 An example application of this is
118
119 ppmchange -remainder=black red red
120
121 to lift only the red portions from an image, or
122 ppmchange -remainder=black red white | ppmtopgm
123
124 to create a mask file for the red portions of the image.
125
126
127
128
130 pgmtoppm(1), ppmcolormask(1), ppm(1)
131
132
134 Wilson H. Bent. Jr. (whb@usc.edu) with modifications by Alberto Acco‐
135 mazzi (alberto@cfa.harvard.edu)
136
138 This manual page was generated by the Netpbm tool 'makeman' from HTML
139 source. The master documentation is at
140
141 http://netpbm.sourceforge.net/doc/ppmchange.html
142
143netpbm documentation December 2016 Ppmchange User Manual(0)