[Numpy-discussion] first recarray steps
Tue May 20 11:08:26 CDT 2008
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.
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.
Also, you probably want a uint8 dtype, giving you 0-255 for each byte.
Christopher Barker, Ph.D.
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
More information about the Numpy-discussion