[fitsbits] Re: Reading floating point FITS files

Rob Seaman seaman at noao.edu
Tue Nov 11 12:45:25 EST 2003


John Green writes:

> To make it more clear: I am restricted to using a toolkit for
> displaying the images. To be able to display the images correctly, I
> have got to pass to the toolkit a buffer containing RGB data for each
> pixel. So for each pixel I have to provide the toolkit with 3 bytes:
> one for red, one for green, one for blue.
> 
> I don't know how is the RGB values stored in the 32, 64 floating point
> data types of FITS files.

FITS is a transport and archival format for representing tables and
multidimensional arrays of scientific measurements - it is not a display
format like GIF or JPEG, for instance.  The astronomical community does
have tools for displaying FITS files - and even tools for displaying
full color representations of FITS and other astronomical images.
But these tools require either explicit or implicit decisions on the
part of the user about what values represent what grayscale levels or
colors.

Typically a FITS image might represent a grayscale image taken through
some UBVRI filter - the filter might be wideband and correspond to some
"color" - or the filter might be narrowband and really have meaning only
in reference to some spectral feature (at some relative radial velocity).
By taking three wideband FITS images roughly covering the blue, green
and red parts of the visible spectrum, software can composite a full
color image that roughly approximates what some astronomical object
would look like to the human eye - if the human eye were 8 meters
across :-)  Perceived color only really means something for bright
objects.

To answer your specific question, a single FITS image is typically
displayed as a grayscale representation.  Astronomical display clients
usually allow adjusting the brightness and contrast (or "window" and
"stretch") on the fly by moving sliders or even just the mouse.  If
your toolkit requires RGB values, your default should likely be to
simply scale the image values into the 8 bit range and then write the
same number into each of the three bytes.  You might also fiddle around
with fancier features such as mapping three different images to the
three different colors and overlaying them.

Rob Seaman
National Optical Astronomy Observatory



More information about the fitsbits mailing list