1Pambackground User Manual(0)                      Pambackground User Manual(0)
2
3
4

NAME

6       pambackground - create a mask of the background area of an image
7
8

SYNOPSIS

10       pambackground
11
12       [netpbmfile]
13
14       [-verbose=]
15
16       Minimum  unique  abbreviations  of options are acceptable.  You may use
17       double hyphens instead of single hyphen to denote options.  You may use
18       white space in place of the equals sign to separate an option name from
19       its value.
20
21
22

DESCRIPTION

24       This program is part of Netpbm(1).
25
26       pambackground reads a PNM or PAM image as input.  It generates as  out‐
27       put  a  PAM  image  that identifies the background area of the image (a
28       mask).
29
30       To identify the background, pambackground assumes the image is a  fore‐
31       ground  image, smaller than the total image size, placed over a single-
32       color background.  It assumes that foreground image is solid -- it does
33       not  have  holes  through which the background can be seen.  So in spe‐
34       cific, pambackground first identifies the background color, then  finds
35       all contiguous pixels of that color in regions touching any edge of the
36       image.  Think of it as starting at each of the four  edges  and  moving
37       inward  and  spreading  out  as far as possible until it hits pixels of
38       another color (the foreground image).
39
40       pambackground identifies the background color as follows: If any 3 cor‐
41       ners  of the image are the same color, that's the background color.  If
42       not, but 2 corners are the same color,  the  background  color  is  the
43       color  of a pair of identically colored corners in this priority order:
44       top, right, left, bottom.  If no two corners have the same  color,  the
45       background color is the color of the upper left corner.
46
47       In  a  typical  photograph,  the area that you would consider the back‐
48       ground is many shades of a color, so to pambackground  it  is  multiple
49       colors  and pambackground will not meaningfully identify the background
50       of your image.  To use pambackground in this case, you might  use  ppm‐
51       change  to  change all similar colors to a single one first.  For exam‐
52       ple, if the photograph is a building against a blue sky, where  nothing
53       remotely  sky-blue  appears in the building, you could use ppmchange to
54       change all pixels within 20% of "SkyBlue" to SkyBlue, then run pamback‐
55       ground on it.
56
57       You  might  even  extract  the argument for ppmchange from the image in
58       question, using pamgetcolor.  In the foregoing  example,  we  knew  the
59       background  was  approximately  SkyBlue, but if we didn't we could just
60       get the color of the top left pixel, in a form suitable for  the  color
61       arguments of ppmchange like this:
62
63           $ color=$(pamgetcolor 0,0 -infile=/tmp/bodyskl|cut --fields=2 -delim=' ')
64
65       A  more convenient means of dealing with a multi-shade background is to
66       use pnmquant to produce a version of the image with a very small number
67       of colors.  The background would likely then be all one color.
68
69       If  the  pnmquant and ppmchange methods above do not adequately distin‐
70       guish foreground colors from background colors,  you  can  try  a  more
71       elaborate  method using pnmremap.  If you can manually create a palette
72       with one color to which all the  background  pixels  are  similar,  and
73       other colors to which the foreground pixels are similar, you can use it
74       as input to pnmremap to create a smarter version of what you  get  with
75       the pnmquant or ppmchange methods, so that pambackground is more likely
76       to separate background from foreground as your eye does.
77
78       The PAM that pambackground creates has a single plane, with a maxval of
79       1.   The sample value 1 means background; 0 means foreground.  There is
80       no tuple type.  Some older programs (but none that are part of  Netpbm)
81       don't  know  what a PAM is and expect a mask to be in the form of a PGM
82       or PBM image.  To convert pambackground's output to PBM,  use  pamtopnm
83       -assume.  To convert to PGM, use pgmtopgm.
84
85       netpbmfile  is  the file specification of the input file, or - to indi‐
86       cate Standard Input.  The default is Standard Input.
87
88       A common use for a background mask is with pamcomp.  You could  replace
89       the  entire  background  (or  foreground)  of your image with something
90       else.
91
92       Another common use is to make an image with the background  transparent
93       (in some image format that has a concept of transparency) so that image
94       can be overlaid onto another image later.  Netpbm's converters to image
95       formats  that  have  transparency  (e.g. PNG) let you use the mask that
96       pambackground generates to identify the transparent areas for the  out‐
97       put.  You can create a PAM image with transparency with pamstack.
98
99       To  simply  make a mask of all the areas of a specified color, use ppm‐
100       colormask.  If you have a unique background  color  (one  that  doesn't
101       occur  in  the foreground) and know what it is, this can create a back‐
102       ground mask in cases that pambackground cannot: where  there  are  see-
103       through holes in the foreground image.
104
105
106

OPTIONS

108       In  addition  to  the options common to all programs based on libnetpbm
109       (most notably -quiet, see
110        Common Options ⟨index.html#commonoptions⟩ ), pambackground  recognizes
111       the following command line option:
112
113
114
115
116       -verbose
117              Tell interesting facts about the process.
118
119
120
121

EXAMPLES

123           $ pambackground test.ppm | pnminvert >/tmp/bgmask.pgm
124           $ pamcomp -alpha=bgmask.pgm test.ppm wallpaper.ppm >output.ppm
125           $ pnmquant 5 test.pgm | pambackground test.ppm >/tmp/bgmask.pam
126
127
128

SEE ALSO

130       ppmcolormask(1),  pamcomp(1),  ppmchange(1),  pnmquant(1), pnmremap(1),
131       pamtopnm(1), pgmtopgm(1), pamstack(1), pamgetcolor(1), pnm(1), pam(1),
132
133

HISTORY

135       pambackground was new in Netpbm 10.37 (December 2006).
136

DOCUMENT SOURCE

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/pambackground.html
142
143netpbm documentation           24 November 2014   Pambackground User Manual(0)
Impressum