PIL FITs image decoder
Robert Kern
robert.kern at gmail.com
Tue Nov 22 17:22:56 EST 2005
jbrewer wrote:
[I wrote:]
>>If you can bear having two copies in memory, Image.frombuffer()
>>generally does the trick.
>
> What arguments do you pass to this function, and do you flatten the
> array from the FITs image? I this but got garbage out for the image.
The array would have to be contiguous, which it may not be immediately
coming out of PyFITS. You also need to be sure that you are using the
right mode for the data.
In [7]: import Image
In [8]: import numarray
In [9]: z = numarray.zeros((256,256)).astype(numarray.UInt8)
In [10]: z[128,:] = 255
In [11]: img = Image.frombuffer('L', (256,256), z)
That creates a black image with a white, horizontal line in the middle.
--
Robert Kern
robert.kern at gmail.com
"In the fields of hell where the grass grows high
Are the graves of dreams allowed to die."
-- Richard Harter
More information about the Python-list
mailing list