@cindex binary mask
@cindex mask, binary
@cindex weight mask
@cindex mask, weight
A @dfn{binary mask} indicates for every pixel of an image if this
pixel must be considered in further processing, or ignored.  For a
@dfn{weight mask}, the value of the mask determines how much the pixel
contributes, zero again meaning ``no contribution''.

Masks arise in two places: as part of the input files and as separate
files, showing the actual pixel weights prior to image blendung or
fusion.  We shall explore both occurrences in the next sections.


@c @node Input File Masks
@section Masks in Input Files
@cindex mask, input files
@cindex input mask

Each of the input files for Enfuse and Enblend can contain its own
mask.  Both applications interpret them as binary masks no matter how
many bits per image pixel they contain.

@pindex identify @r{(ImageMagick)}
@pindex tiffinfo @r{(libtiff)}
Use ImageMagick's @command{identify} or, for @acronym{TIFF} files,
@command{tiffinfo} to inquire quickly whether a file contains a mask.
@ref{Helpful Programs} shows where to find these programs on the web.

@example
$ identify -format "%f %m %wx%h %r %q-bit" remapped-0000.tif
remapped-0000.tif TIFF 800x533 DirectClassRGBMatte 8-bit
                                             ^^^^^ mask
@end example

@example
$ tiffinfo remapped-0000.tif
TIFF Directory at offset 0x1a398a (1718666)
  Subfile Type: (0 = 0x0)
  Image Width: 800 Image Length: 533
  Resolution: 150, 150 pixels/inch
  Position: 0, 0
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: PackBits
  Photometric Interpretation: RGB color
  Extra Samples: 1<unassoc-alpha>            <<<<< mask
  Orientation: row 0 top, col 0 lhs
  Samples/Pixel: 4                           <<<<< R, G, B, and mask
  Rows/Strip: 327
  Planar Configuration: single image plane
@end example

@noindent
The ``Matte'' part of the image class and the ``Extra Samples'' line
tell us that the file features a mask.  Also, many interactive image
manipulation programs show the mask as a separate channel, sometimes
called ``Alpha''.  There, the white (high mask value) parts of the
mask enable pixels and black (low mask value) parts suppress them.

The multitude of terms all describing the concept of a mask is
confusing.

@table @asis
@item Mask
A mask defines a selection of pixels.  A value of zero represents an
unselected pixel.  The maximum value (``white'') represents a selected
pixel and the values between zero and the maximum are partially
selected pixels.  See
@uref{http://@/gimp-savvy.com/@/BOOK/@/index.html?node42.html,
Gimp-Savy}.

@item Alpha Channel
The alpha channel stores the transpacency value for each pixel,
typically in the range from zero to one.  A value of zero means the
pixel is completely transparent, thus does not contribute to the
image.  A value of one on the other hand means the pixel is completely
opaque.

@item Matte
The notion ``matte'' as used by ImageMagick refers to an inverted
alpha channel, more precisely: 1 - alpha.  See
@uref{http://@/www.imagemagick.org/@/Usage/@/channels/@/#trans,
ImageMagick} for further explanations.
@end table

Enblend and Enfuse only consider pixels that have an associated mask
value other than zero.  If an input image does not have an alpha
channel, Enblend warns and assumes a mask of all non-zero values, that
is, it will use every pixel of the input image for fusion.

Stitchers like @command{nona} add a mask to their output images.

Sometimes it is helpful to manually modify a mask before fusion.  For
example to suppress unwanted objects (insects and cars come into mind)
that moved across the scene during the exposures.  If the masks of all
input images are black at a certain position, the output image will
have a hole in that position.


@c @node Weight Mask Files
@section Weight Mask Files
@cindex mask, weight
@cindex weight mask

...
