man-pages/man1/pbmmask.1.html
2021-03-31 01:06:50 +01:00

135 lines
3.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of pbmmask</TITLE>
</HEAD><BODY>
<H1>pbmmask</H1>
Section: User Commands (1)<BR>Updated: 08 August 1989<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="ixAAB"></A>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
pbmmask - create a mask bitmap from a regular bitmap
<A NAME="lbAC">&nbsp;</A>
<H2>SYNOPSIS</H2>
<B>pbmmask</B>
[<B>-expand</B>]
[<I>pbmfile</I>]
<A NAME="lbAD">&nbsp;</A>
<H2>DESCRIPTION</H2>
Reads a portable bitmap as input.
Creates a corresponding mask bitmap and writes it out.
<P>
The color to be interpreted as &quot;background&quot; 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>
<A NAME="ixAAC"></A>
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>
<A NAME="ixAAD"></A>
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 graymaps and pixmaps, using the
<I>pnmarith</I>
tool. For instance:
<PRE>
ppmtopgm obj.ppm | pgmtopbm -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>
<A NAME="ixAAE"></A>
An interesting variation on this is to pipe the mask through the
<I>pnmsmooth</I>
<A NAME="ixAAF"></A>
script before using it. This makes the boundary between the two images less
sharp.
<P>
<P>
<A NAME="lbAE">&nbsp;</A>
<H2>OPTIONS</H2>
<DL COMPACT>
<DT id="1"><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
<I>pbmlife</I>
tool into a general cellular automaton tool...)
<P>
<P>
</DL>
<A NAME="lbAF">&nbsp;</A>
<H2>SEE ALSO</H2>
<B><A HREF="/cgi-bin/man/man2html?1+ppmcolormask">ppmcolormask</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+pnmpaste">pnmpaste</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+pnminvert">pnminvert</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?5+pbm">pbm</A></B>(5),
<B><A HREF="/cgi-bin/man/man2html?1+pnmarith">pnmarith</A></B>(1),
<B><A HREF="/cgi-bin/man/man2html?1+pnmsmooth">pnmsmooth</A></B>(1)
<A NAME="lbAG">&nbsp;</A>
<H2>AUTHOR</H2>
Copyright (C) 1988 by Jef Poskanzer.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="2"><A HREF="#lbAB">NAME</A><DD>
<DT id="3"><A HREF="#lbAC">SYNOPSIS</A><DD>
<DT id="4"><A HREF="#lbAD">DESCRIPTION</A><DD>
<DT id="5"><A HREF="#lbAE">OPTIONS</A><DD>
<DT id="6"><A HREF="#lbAF">SEE ALSO</A><DD>
<DT id="7"><A HREF="#lbAG">AUTHOR</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:21 GMT, March 31, 2021
</BODY>
</HTML>