[AstroPy] Moving Ahead with Raw Image Conversion

Anne Archibald peridot.faceted at gmail.com
Tue Apr 14 14:29:24 EDT 2009

2009/4/14 Wayne Watson <sierra_mtnview at sbcglobal.net>:
> Well, one more question about manipulation.
> rawim_numpy = numpy.fromfile('sent_internal.raw', dtype='uint8')
> was a good device for producing this from a file:
>  array([1, 1, 1, ..., 1, 1, 1], dtype=uint8)
> a numpy array. In my program, I'm getting* the image in a string 307200
> "characters" long. Is there a device (fromstring?) that would do this in
> one fell swoop to get a numpy array?
> * as here: img_string=self.current_image.tostring()

There is, yes, but if what you have is a PIL image, you can make a
numpy array directly from the underlying memory:

Incidentally, if you want to do image processing on the contents of a
FITS file, you might try scipy's ndimage tools. They are likely to be
a better fit to the sort of tasks you want to do than PIL's image
processing. There may also be more astronomical image processing
libraries available (pyraf?), I haven't really looked for them.


More information about the AstroPy mailing list