[Numpy-discussion] numpy.choose question
Sat May 23 10:14:04 CDT 2009
I have a question about the numpy.choose method.
I'm working with rgb image arrays (converted using PIL's 'asarray'),
and would like to combine data from multiple images. The choose method
seemed just the thing for what i want to do: creating new images from
multiple source images and an index mask. However, it looks like the
choose method chokes on anything but single-value data arrays. As soon
as I give it source arrays made up of RGB int triplets (e.g.,
[0,128,255]), it complains with a "ValueError: too many dimensions"
My hope was that the choose method would return an array made up of
the same kind of elements that the source arrays are made up of (in
this case, RGB triplets), but it seems to only like scalars. I guess
it sees my image arrays at 3D arrays, and doesn't know what to do with
them. Is that right? I suppose I could pre-split my images into
separate R, G, and B arrays, run them through np.choose, and then
recombine the results, but that seems clunky.
Any advice welcome. Thanks
More information about the Numpy-discussion