blob: 716a1ee0c284385c8b5e48248391d275826f007e (
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
105
106
107
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//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>
<A NAME="lbAB"> </A>
<H2>NAME</H2>
pbmmask - create a mask bitmap from a regular bitmap
<A NAME="lbAC"> </A>
<H2>SYNOPSIS</H2>
<B>pbmmask</B>
[<B>-expand</B>]
[<I>pbmfile</I>]
<A NAME="lbAD"> </A>
<H2>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 > objmask
pnmpaste < dest -and objmask <x> <y> | pnmpaste -or obj <x> <y>
</PRE>
For objects with a white background, you can either invert them or
add a step:
<PRE>
pbmmask obj > objmask
pnminvert objmask | pnmpaste -and obj 0 0 > blackback
pnmpaste < dest -and objmask <x> <y> | pnmpaste -or blackback <x> <y>
</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 > objmask.pbm
pnmarith -multiply dest.ppm objmask.pbm > t1.ppm
pnminvert objmask.pbm | pnmarith -multiply obj.ppm - > 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.
<A NAME="lbAE"> </A>
<H2>OPTIONS</H2>
<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>
<A NAME="lbAF"> </A>
<H2>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>,
<A NAME="lbAG"> </A>
<H2>AUTHOR</H2>
Copyright (C) 1988 by Jef Poskanzer.
<HR>
<A NAME="index"> </A>
<H2>Table Of Contents</H2>
<UL>
<LI><A HREF="#lbAB">NAME</A>
<LI><A HREF="#lbAC">SYNOPSIS</A>
<LI><A HREF="#lbAD">DESCRIPTION</A>
<LI><A HREF="#lbAE">OPTIONS</A>
<LI><A HREF="#lbAF">SEE ALSO</A>
<LI><A HREF="#lbAG">AUTHOR</A>
</UL>
</BODY>
</HTML>
|