Bash Cures Cancer
Learn the UNIX/Linux command line

Home     Man Pages     SpamDefeator


				   pnmremap

   Updated: 01 January 2002
   Table Of Contents

NAME

   pnmremap  - replace colors in a PNM image with colors from an-
other set

SYNOPSIS

   pnmremap	[-floyd|-fs|-nfloyd|-nofs]	[-firstisdefault]
[-verbose]
   [-mapfile=mapfile] [-missingcolor=color] [pnmfile]

   All	options	 can be abbreviated to their shortest unique pre-
fix. You may use
   two hyphens instead of one to designate an option. You may use
either white
   space  or an equals sign between an option name and its value.

DESCRIPTION

   This program is part of Netpbm.

   pnmremap replaces the colors in an input image with those from
a colormap
   you	specify.  Where	 a  color in the input is not in the col-
ormap, you have
   three choices: 1) choose the closest color from the	colormap;
2) choose the
   first  color	 from the colormap; 3) use a color specified by a
command option.
   (In this latter case, if the color you specify is not in  your
color map, the
   output  will not necessarily contain only colors from the col-
ormap).

   Two reasons to do this are: 1) you want to reduce  the  number
of colors in
   the	input  image;  and 2) you need to feed the image to some-
thing that can
   handle only certain colors.

   To reduce colors, you can generate the colormap  with  pnmcol-
ormap. Example: pnmcolormap testimg.ppm 256 >colormap.ppm

pnmremap -map=colormap.ppm testimg.ppm >reduced_testimg.ppm

   To limit colors to a certain set, a typical example is to cre-
ate an image
   for posting on the World Wide Web,  where  different	 browsers
know different
   colors.  But	 all  browsers	are supposed to know the 216 "web
safe" colors
   which are essentially all the colors you can	 represent  in	a
PPM image with a
   maxval of 5. So you can do this: pamseq 3 5 >websafe.pam

pnmremap -map=webafe.pam testimg.ppm >websafe_testimg.ppm

   Another  useful  colormap is one for the 8 color IBM TTL color
set, which you
   can create with pamseq 3 1 >ibmttl.pam

   If you want to quantize one image to use the colors in another
one, just use
   the	second	one  as	 the mapfile. You don't have to reduce it
down to only one
   pixel of each color, just use it as is.

   The output image has the same type and maxval as the map file.

PARAMETERS

   There is one parameter, which is required: The file specifica-
tion of the
   input PNM file.

OPTIONS

   -mapfile=mapfilename
	  This names the file that contains the PPM color map.	A
PPM color map
	  is  simply  a	 PPM  image  which contains the colors to
which you want to
	  remap the colors in the input image.	Normally,  a  PPM
color map has
	  exactly  one	pixel of each color, and is a single row.
But it can be
	  any shape and repeat colors too.
	  This option is mandatory.
   -floyd
   -fs
   -nofloyd
   -nofs
	  These options determine whether Floyd-Steinberg dither-
ing is done.
	  Without  Floyd-Steinberg, the selection of output color
of a pixel is
	  based	 on the color of  only	the  corresponding  input
pixel. With
	  Floyd-Steinberg,  multiple  input pixels are considered
so that the
	  average color of an area tends to stay  more	the  same
than without
	  Floyd-Steinberg.  For example, if you map an image with
a black, gray,
	  gray, and white pixel adjacent, through a map that con-
tains only
	  black and white, it might result in an output of black,
black, white,
	  white. Pixel-by-pixel mapping would  instead	map  both
the gray pixels
	  to the same color.
	  Floyd-Steinberg   gives  vastly  better  results on im-
ages where
	  unmodified quantization has banding or other artifacts,
especially
	  when	going  to  a  small  number of colors such as the
above IBM set.
	  However, it does take substantially more CPU time.
	  -fs is a synomym for -floyd. -nofs  is  a  synonym  for
-nofloyd.
	  The default is -nofloyd.
   -firstisdefault
	  This affects what happens with a pixel in the input im-
age whose color
	  is  not  in  the  map	 file.	If  you	 specify  neither
-firstisdefault nor
	  -missingcolor, pnmremap chooses for the output the col-
or in the map
	  which is closest  to	the  color  in	the  input.  With
-firstisdefault,
	  pnmremap  instead uses the first color in the colormap.
	  If you specify -firstisdefault, the maxval of your  in-
put must match
	  the maxval of your colormap.
   -missingcolor=color
	  This affects what happens with a pixel in the input im-
age whose color
	  is  not  in  the  map	 file.	If  you	 specify  neither
-firstisdefault nor
	  -missingcolor, pnmremap chooses for the output the col-
or in the map
	  which is closest to the color in the input. With -miss-
ingcolor,
	  pnmremap uses color. color need not be in the colormap.
	  If you specify -missingcolor, the maxval of your  input
must match the
	  maxval of your colormap.
   -verbose
	  Display helpful messages about the mapping process.



SEE ALSO

   pnmcolormap,	 pamseq,  pnmquant,  ppmquantall,  pnmdepth,  pp-
mdither, ppmquant,
   ppm

AUTHOR

   Copyright (C) 1989, 1991 by Jef Poskanzer.
     _________________________________________________________________



Table Of Contents

     * NAME
     * SYNOPSIS
     * DESCRIPTION
     * PARAMETERS
     * OPTIONS
     * SEE ALSO
     * AUTHOR




















UNIX/Linux commands referenced on this page:
  1. replace
  2. pnmcolormap
  3. which
  4. pamseq
  5. as
  6. file
  7. more
  8. pnmquant
  9. ppmquantall
  10. pnmdepth