[Numpy-discussion] first recarray steps

Anne Archibald peridot.faceted@gmail....
Wed May 21 13:44:31 CDT 2008


2008/5/21 Vincent Schut <schut@sarvision.nl>:
> Christopher Barker wrote:
>>
>> Also, if you image data is rgb, usually, that's a (width, height, 3)
>> array: rgbrgbrgbrgb... in memory. If you have a (3, width, height)
>> array, then that's rrrrrrr....gggggggg......bbbbbbbb. Some image libs
>> may give you that, I'm not sure.
>
> My data is. In fact, this is a simplification of my situation; I'm
> processing satellite data, which usually has more (and other) bands than
> just rgb. But the data is definitely in shape (bands, y, x).

You may find your life becomes easier if you transpose the data in
memory. This can make a big difference to efficiency. Years ago I was
working with enormous (by the standards of the day) MATLAB files on
disk, storing complex data. The way (that version of) MATLAB
represented complex data was the way you describe: matrix of real
parts, matrix of imaginary parts. This meant that to draw a single
pixel, the disk needed to seek twice... depending on what sort of
operations you're doing, transposing your data so that each pixel is
all in one place may improve cache coherency as well as making the use
of record arrays possible.

Anne


More information about the Numpy-discussion mailing list