.TL
Ppmchange User Manual
.SH 1
ppmchange
.LP
Updated: September 2005
.br
Table Of Contents
.SH 2
NAME
.LP
ppmchange - change all pixels of one color to another in a PPM image
.SH 2
SYNOPSIS
.LP
\fBppmchange\fR
[\fB-closeness=\fR\fIcloseness_percent\fR]
[\fB-remainder=\fR\fIremainder_color\fR]
[\fB-closeok\fR]
[\fIoldcolor newcolor\fR] ...
[\fIppmfile\fR]
.SH 2
EXAMPLES
.LP
.DS L
\fBppmchange red blue redimage.ppm >blueimage.ppm\fR
\fBppmchange red red -remainder=black myimage.ppm >redblack.ppm\fR
\fBppmchange -closeness=90 white white black black\fR
.DE
.SH 2
DESCRIPTION
.LP
.LP
This program is part of Netpbm.
.LP
\fBppmchange\fR reads a PPM image as input and changes all pixels of
colr \fIoldcolor\fR to color \fInewcolor\fR.
You may specify up to 256 oldcolor/newcolor pairs on the command line.
\fBppmchange\fR leaves all colors not mentioned unchanged, unless you
specify the \fB-remainder\fR option, in which case they are all
changed to the single specified color.
.LP
You can specify that colors similar, but not identical, to the ones
you specify get replaced by specifying a "closeness" factor.
.LP
Specify the colors as described for the argument of the \fBppm_parsecolor()\fR
library routine.
.LP
If a pixel matches two different \fIoldcolor\fRs, \fBppmchange\fR
replaces it with the \fInewcolor\fR of the leftmost specified one.
.LP
The maxval of the output image is the same as that of the input
image. If a \fInewcolor\fR you specify cannot be exactly represented
in that maxval, \fBppmchange\fR assumes a color that is as close as
possible to what you specified but can be represented with your
maxval. Unless you specify the \fB-closeok\fR option,
\fBppmchange\fR issues a warning that it is using an approximation.
.LP
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 \fBpamdepth\fR to make the maxval
of your input something consistent with your colors. 255 is usually a
good choice.
.LP
Before Netpbm 10.22 (April 2004), \fBppmchange\fR always behaved as
if the user specified \fB-closeok\fR and there was no \fB-closeok\fR
option.
.SH 2
OPTIONS
.LP
.RS
.IP "\fB-closeness \fR\fIcloseness_percent\fR"
\fIcloseness\fR is an integer per centage 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.
.LP
A pixel gets replaced if the distance in color between it and the
color you specified is less than or equal to \fIcloseness\fR per cent
of the maxval.
.LP
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%.
.LP
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
\fBppmchange\fR'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.
.LP
Maybe \fBppmchange\fR will be enhanced some day to do chrominance
analysis.
.IP "\fB-closeok\fR"
This option affects how \fBppmchange\fR interprets a color you
specify in the arguments. When you specify this option, \fBppmchange\fR
may use a color close to, but not the same as what you specify. See
the description section for details.
.LP
This option was new in Netpbm 10.22 (April 2004). Before that,
\fBppmchange\fR always behaved as if you specified this option.
.IP "\fB-remainder \fR\fIcolor\fR"
\fBppmchange\fR changes all pixels which are not of a color for
which you specify an explicit replacement color on the command line to
color \fIcolor\fR.
.LP
An example application of this is
.DS L
\fBppmchange -remainder=black red red\fR
.DE
to lift only the red portions from an image, or
.DS L
\fBppmchange -remainder=black red white | ppmtopgm\fR
.DE
to create a mask file for the red portions of the image.
.RE
.SH 2
SEE ALSO
.LP
\fBpgmtoppm\fR,
\fBppmcolormask\fR,
\fBppm\fR
.SH 2
AUTHOR
.LP
Wilson H. Bent. Jr. (whb@usc.edu)
with modifications by Alberto Accomazzi (alberto@cfa.harvard.edu)
.br
\l'5i'
.SH 2
Table Of Contents
.LP
.IP \(bu
NAME
.IP \(bu
SYNOPSIS
.IP \(bu
EXAMPLES
.IP \(bu
DESCRIPTION
.IP \(bu
OPTIONS
.IP \(bu
SEE ALSO
.IP \(bu
AUTHOR
.LP
|