Plan 9 from Bell Labs’s /usr/web/sources/contrib/pac/sys/doc/netpbm/ms/pbmmask.ms

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


.TL
Pbmmask User Manual
.SH 1
pbmmask
.LP
Updated: 08 August 1989
.br
Table Of Contents
.SH 2
NAME
.LP
pbmmask - create a mask bitmap from a regular bitmap
.SH 2
SYNOPSIS
.LP
\fBpbmmask\fR
[\fB-expand\fR]
[\fIpbmfile\fR]
.SH 2
DESCRIPTION
.LP
.LP
This program is part of Netpbm.
.LP
\fBpbmmask\fR reads a PBM image as input and Generates a
corresponding mask of the foreground areas as another PBM image.
.LP
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.
.LP
This lets you do a masked paste like this, for objects with a black
background:
.DS L
    pbmmask obj > objmask
    pnmpaste < dest -and objmask <x> <y> | pnmpaste -or obj <x> <y>
.DE
For objects with a white background, you can either invert them or
add a step:
.DS L
    pbmmask obj > objmask
    pnminvert objmask | pnmpaste -and obj 0 0 > blackback
    pnmpaste < dest -and objmask <x> <y> | pnmpaste -or blackback <x> <y>
.DE
Note that this three-step version works for objects with black backgrounds
too, if you don't care about the wasted time.
.LP
You can also use masks with graymaps and pixmaps, using the
\fIpnmarith\fR tool.  For instance:
.DS L
    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
.DE
An interesting variation on this is to pipe the mask through
\fIpnmsmooth\fR before using it.  This makes the boundary between the
two images less sharp.
.SH 2
OPTIONS
.LP
.RS
.IP "\fB-expand\fR"
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 \fBpbmlife\fR program into a general
cellular automaton tool...)
.RE
.SH 2
SEE ALSO
.LP
\fBppmcolormask\fR,
\fBpnmpaste\fR,
\fBpnminvert\fR,
\fBpnmarith\fR,
\fBpnmsmooth\fR
\fBpbm\fR,
.SH 2
AUTHOR
.LP
Copyright (C) 1988 by Jef Poskanzer.
.br
\l'5i'
.SH 2
Table Of Contents
.LP
.IP \(bu
NAME
.IP \(bu
SYNOPSIS
.IP \(bu
DESCRIPTION
.IP \(bu
OPTIONS
.IP \(bu
SEE ALSO
.IP \(bu
AUTHOR
.LP

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.