Convert numpy.ndarray into "normal" array

Johannes Bauer dfnsonfsduifb at gmx.de
Fri Apr 24 11:56:16 CEST 2009


Hi group,

I'm confused, kind of. The application I'm writing currently reads data
from a FITS file and should display it on a gtk window. So far I have:

[...]
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, width, height)
pb_pixels = pb.get_pixels_array()

print(type(fits_pixels))
print(type(pb_pixels))

which gives

<type 'numpy.ndarray'>
<type 'array'>

So now I want to copy the fits_pixels -> pb_pixels. Doing

pb_pixels = fits_pixels

works and is insanely fast, however the picture looks all screwed-up
(looks like a RGB picture of unititialized memory, huge chunks of 0s
interleaved with lots of white noise).

Doing the loop:

for x in range(width):
	for y in range(height):
		pb_pixels[y, x] = fits_pixels[y, x]

works as expected, but is horribly slow (around 3 seconds for a 640x480
picture).

So now I've been trying to somehow convert the array in a fast manner,
but just couldn't do it. What exactly is "array" anyways? I know
"array.array", but that's something completely different, right? Does
anyone have hints on how to go do this?

Kind regards,
Johannes

-- 
"Meine Gegenklage gegen dich lautet dann auf bewusste Verlogenheit,
verlästerung von Gott, Bibel und mir und bewusster Blasphemie."
         -- Prophet und Visionär Hans Joss aka HJP in de.sci.physik
                         <48d8bf1d$0$7510$5402220f at news.sunrise.ch>



More information about the Python-list mailing list