Christopher Barker wrote: > > Vincent Schut wrote: >> Lets say I have a rgb image of arbitrary size, as a normal ndarray >> (that's what my image reading lib gives me). Thus shape is >> (3,ysize,xsize), dtype = int8. How would I convert/view this as a >> recarray of shape (ysize, xsize) with the first dimension split up into >> 'r', 'g', 'b' fields? No need for 'x' and 'y' fields. > > Take a look in this list for a thread entitled "recarray fun" about a > month ago -- you'll find some more discussion of approaches.
Well, actually that thread was my inspiration to take a closer look into recarrays... > > 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). > > Also, you probably want a uint8 dtype, giving you 0-255 for each byte. Same story. In fact, in this case it's int16, but can actually be any data type, even floats, even complex. But thanks for the thoughts :-) > > -Chris > > > _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion