IRAF pixel mask support in FITS files
The FITS kernel was modified to add support for storing images in
extensions as compressed pixel masks. The mask is stored as a
binary table using the "ZIMAGE" (compressed image) convention
proposed by White, Greenfield, Pence, and Tody in 1999:
http://heasarc.gsfc.nasa.gov
/docs/software/fitsio/compression/compress_image.html
In the current implementation only the "PLIO_1" compression
algorithm is implemented. Mask extensions may be read or written
directly by the kernel. When writing a new extension it will be
appended to the MEF file. To append an image to a MEF file as
a mask, include "type=mask" in the image kernel section when the
output image is opened.
Masks are interfaced to the system as images and may be read and
written like any other image via IMIO. They have a normal image
header and can be manipulated with any program that deals with
images. The pixel type is INT.
It is also possible to access a mask image as a PLIO mask. An
IMSTATI query for IM_PLDES parameter will return the PLIO mask
descriptor. While a mask extension is opened under IMIO it is
represented as a PLIO mask and may be accessed in this form like
any other mask.
The mask image is stored in the FITS binary table (BINTABLE)
extension when the image is closed, and is loaded from the extension
when the image is opened. The compression representation used to
store the mask in the binary table is the same as is used within
PLIO. The new (V2.12) encoding is used, allowing very large masks
to be stored. Currently masks up to 3D are supported. Data on
each 2D mask plane will be compressed in both X and Y as with PLIO.
The depth of the mask is preserved.
Although a mask is stored as a binary table the format of the
table is not completely general. In the current implementation
there can be only one column in the table (COMPRESSED_DATA).
This is an integer-valued variable length array column containing,
for each line of the N-dimensional image, the PLIO compressed
version of that image line. The actual compressed data is stored
in the heap area of the table. Multiple image lines may point to
the same compressed line list, e.g., to store the empty line or to
provide compression in Y.
Examples
1) Copy a pixel mask file into a FITS extension; notice the 'type'
parameter with value 'mask' that is necessary to create a
BINARY table otherwise an IMAGE extension will result.
im> imcopy mtest.pl mfile.fits[type\=mask]
If you are under the 'cl' you need to escape the '=' sign.
2) Append a pixel mask to a MEF file.
im> imcopy pixr.pl pixrp.fits[pix1,type\=mask,append]
3) List the header.
im> imheader pixrp.fits[pix1] long+ user+
4) List the actual fits header of the above image.
im> fitsutil # Load external package
fi> fxheader pixrp.fits[1] l+