about summary refs log tree commit diff
path: root/pbmmask.html
blob: 5916cdbfd8b7f9e6323ef54991d348ca19fc1b6a (plain) (blame)
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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.3//EN">
<html><head><title>Pbmmask User Manual</title></head>
<body>
<h1>pbmmask</h1>
Updated: 08 August 1989
<br>
<a href="#index">Table Of Contents</a>

<h2>NAME</h2>

pbmmask - create a mask bitmap from a regular bitmap

<h2 id="synopsis">SYNOPSIS</h2>

<b>pbmmask</b>
[<b>-expand</b>]
[<i>pbmfile</i>]

<h2 id="description">DESCRIPTION</h2>

<p>This program is part of <a href="index.html">Netpbm</a>.

<p><b>pbmmask</b> reads a PBM image as input and Generates a
corresponding mask of the foreground areas as another PBM image.

<p>The color to be interpreted as "background" is
determined automatically.  Regardless of which color is background,
the mask will be white where the background is and black where the
figure is.

<p>This lets you do a masked paste like this, for objects with a black
background:

<pre>
    pbmmask obj &gt; objmask
    pnmpaste &lt; dest -and objmask &lt;x&gt; &lt;y&gt; | pnmpaste -or obj &lt;x&gt; &lt;y&gt;
</pre>

For objects with a white background, you can either invert them or
add a step:
<pre>
    pbmmask obj &gt; objmask
    pnminvert objmask | pnmpaste -and obj 0 0 &gt; blackback
    pnmpaste &lt; dest -and objmask &lt;x&gt; &lt;y&gt; | pnmpaste -or blackback &lt;x&gt; &lt;y&gt;
</pre>

Note that this three-step version works for objects with black backgrounds
too, if you don't care about the wasted time.

<p>You can also use masks with grayscale and color images, using the
<i>pnmarith</i> tool.  For instance:

<pre>
    ppmtopgm obj.ppm | pamditherbw -threshold | pbmmask &gt; objmask.pbm
    pnmarith -multiply dest.ppm objmask.pbm &gt; t1.ppm
    pnminvert objmask.pbm | pnmarith -multiply obj.ppm - &gt; t2.ppm
    pnmarith -add t1.ppm t2.ppm
</pre>

An interesting variation on this is to pipe the mask through
<i>pnmsmooth</i> before using it.  This makes the boundary between the
two images less sharp.

<h2 id="options">OPTIONS</h2>

<p>In addition to the options common to all programs based on libnetpbm
(most notably <b>-quiet</b>, see <a href="index.html#commonoptions">
Common Options</a>), <b>pbmmask</b> recognizes the following
command line option:

<dl compact>
<dt><b>-expand</b>

<dd>Expands the mask by one pixel out from the image.  This is useful
if you want a little white border around your image.  (A better
solution might be to turn the <b>pbmlife</b> program into a general
cellular automaton tool...)

</dl>

<h2 id="seealso">SEE ALSO</h2>

<b><a href="ppmcolormask.html">ppmcolormask</a></b>,
<b><a href="pnmpaste.html">pnmpaste</a></b>,
<b><a href="pnminvert.html">pnminvert</a></b>,
<b><a href="pnmarith.html">pnmarith</a></b>,
<b><a href="pnmsmooth.html">pnmsmooth</a></b>
<b><a href="pbm.html">pbm</a></b>,

<h2 id="author">AUTHOR</h2>

Copyright (C) 1988 by Jef Poskanzer.

<hr>
<h2 id="index">Table Of Contents</h2>
<ul>
<li><a href="#synopsis">SYNOPSIS</a>
<li><a href="#description">DESCRIPTION</a>
<li><a href="#options">OPTIONS</a>
<li><a href="#seealso">SEE ALSO</a>
<li><a href="#author">AUTHOR</a>
</ul>
</body>
</html>