Hi Chris 2008/4/30 Christopher Barker <[EMAIL PROTECTED]>: > Someone on the wxPython list posted a nifty recarray example that I > don't quite understand. The idea is to have an array for an RGBA image: > > rgbarec = numpy.dtype({'r':(numpy.uint8,0), > 'g':(numpy.uint8,1), > 'b':(numpy.uint8,2), > 'a':(numpy.uint8,3)}) >
I find manipulating data with records arrays highly intuitive; I had the same approach in mind when I wrote http://www.scipy.org/RecordArrays > One more idea -- is there a way to have two arrays, each with a > different dtype, that point to the same data? maybe: > > RGBImage = numpy.zeros(shape, dtype=rgbarec ) > > IntImage = RGBImage.view() > IntImage.dtype = numpy.uint32 > > That way you could work with it either way, whichever was easier in the > context. That's the way, or just rgba_image.view(numpy.int32). Cheers Stéfan _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion