[Numpy-discussion] Indexing by label in 3rd dimension

Benjamin Root ben.root@ou....
Fri Sep 16 10:34:42 CDT 2011


On Friday, September 16, 2011, Benjamin Root <ben.root@ou.edu> wrote:
>
>
> On Friday, September 16, 2011, Benjamin Landenberger <
benjamin.landenberger@imtek.uni-freiburg.de> wrote:
>> Hello list!
>>
>> I have an array *mask* of shape (a, b) and another array *intensities*
>> of shape (N, a, b), where the values in *mask* range from 0 to N-1. It
>> is somehow similar to label arrays in scipy.ndimage.
>>
>> Now I want to pick those entries from the first dimension of
>> *intensities* which are given by *mask*. The returned array shall again
>> wave shape (a, b).
>>
>> Can this be done with fancy indexing?
>>
>> Thank you,
>>
>> Ben
>>
>
> Try intensities[mask, xrange(a), xrange(b)].
>
> Untested, but it would work for 1d, haven't tried for 2d.
>
> Ben Root
>

Crap, that wouldn't work... Sorry.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110916/bf349236/attachment.html 


More information about the NumPy-Discussion mailing list