[AstroPy] Getting Started with Python and FITS

Peter Erwin erwin at mpe.mpg.de
Wed Apr 1 09:29:55 EDT 2009

On Apr 1, 2009, at 2:28 PM, Wayne Watson wrote:

> Ultimately, I must display it in Python. If numdisplay is it, then  
> that'll likely do. I would have thought pyfits would have a display  
> method.
> At some point, I will want to convert a raw image, 640x480, of some  
> bit depth (8, 16, 24) to a fits format. I might need to convert jpb  
> images to fits too. Comments?

Keep in mind that FITS images are (almost always, if not always)  
grayscale: each pixel has a single
value, though the possible values can be integers (usually 16-bit or  
32-bit) or floating-point.

This is different from, e.g., a standard 24-bit color image, where  
each pixel has three values (one for red,
one for green, and one for blue), and each value is an 8-bit integer.

If your "raw images" are *color* ("24 bits" sounds like a color image,  
and JPEG images are usually
24-bit color images), then you'll have to figure out some way of  
separating them into their individual
red, green, and blue components.  Each separate component could then  
be saved as a separate FITS
file (or, getting more complicated, a single FITS file with three data  

Apologies if you knew this already, but it wasn't clear from your post.


Peter Erwin                   Max-Planck-Insitute for Extraterrestrial
erwin at mpe.mpg.de              Physics, Giessenbachstrasse
tel. +49 (0)89 30000 3695     85748 Garching, Germany
fax  +49 (0)89 30000 3495     http://www.mpe.mpg.de/~erwin

More information about the AstroPy mailing list