[fitsbits] FITS vs. TIFF (or other image formats)

William Pence pence at tetra.gsfc.nasa.gov
Mon Nov 19 13:41:50 EST 2001


Rick Armstrong wrote:
>
> I'm writing an C++ application that gathers images acquired from a
> microsocope with a motorized x-y stage. The app stitches the acquired images
> into extended-field-of-view mosaics. To create mosaics of objects of
> significant size, I need to create enormous image files (at 40X
> magnification, with a 1300x1030 image size, a 1.5 x 1.5mm area gets a file
> that's on the order of tens of GB). In the process of thinking about how to
> read/write/browse files of this size, I realized that astronomers and
> geo-mapper type people must run into this all the time!
> 
> While surfing about, I stumbled on FITS and I have two question for the
> group:
> 
> 1) Why do astronomers use FITS, instead of just writing huge TIFFs or files
> of some other format?
> 
> 2) Can I use CFITSIO to write a "compressed stream", i.e., can I write and
> compress in the same operation using CFITSIO? Is it necessary to create a
> complete, uncompressed file, _then_ compress it? Is this a naive question?

FITS is designed to record the value of image pixels with high precision and
is probably not suitable for your application, especially if you are dealing
with true color images.  To answer your second question, however, CFITSIO
does support a type of image compression that is well suited for very large
images.  The image is first divided into a grid of rectangular subimages (in
many cases it is convenient to treat each row of the original image as a
subimage), then each subimage is compressed and stored as a variable length
array in a row of a FITS binary table.  When application programs read this
'image', CFITSIO will transparently uncompress the appropriate subimages and
return the original image pixel values to the application.  This technique
is especially useful in cases where the application program  usually only
wants to read a small section of the whole image.  CFITSIO then only has to
uncompress the subimages that make up that piece of the image, rather than
having to uncompress the entire huge image.  Several different compression
algorithms are supported, and it can be used for both integer and
floating-point data format images.

For more information see the CFITSIO Reference Guide at:

http://heasarc.gsfc.nasa.gov/docs/software/fitsio/c/c_user/node109.html

or the original paper by White, Greenfield, Pence, and Tody that defines
this format:

http://heasarc.gsfc.nasa.gov/docs/software/fitsio/compression/compress_image.html

-Bill Pence
-- 
____________________________________________________________________
Dr. William Pence                          pence at tetra.gsfc.nasa.gov
NASA/GSFC Code 662         HEASARC         +1-301-286-4599 (voice)     
Greenbelt MD 20771                         +1-301-286-1684 (fax)



More information about the fitsbits mailing list