[SciPy-user] indices, lists and arrays
Wed Jun 6 10:46:04 CDT 2007
On 6/6/07, Francesc Altet <email@example.com> wrote:
> El dc 06 de 06 del 2007 a les 16:13 +0200, en/na Emanuele Zattin va
> > i have something like this:
> > sizes = ndimage.sum(bl_img, labels=bl_l, index=range(1,bl_n+1))
> > sizes = array(sizes)
> > bl_obj_indices = where(sizes<21)
> > bl_l[bl_objects[bl_obj_indices]] = 0
> > sizes was a list, but i converted it to an array in order to use the
> > function where on it
> > where returns an array of arrays, something like (array([14, 17]),)
> > bl_objects is the output of ndimage.find_objects and is a list. this
> > means that the assignment on the last row of the proposed code does
> > not work.
> > is there an elegant solution to solve the problem?
> In order to use fancy indexing, you always need an array as the base,
> so, the next should do the trick:
> bl_l[array(bl_objects)[bl_obj_indices]] = 0
> or, for short:
> bl_l[array(bl_objects)[sizes<21]] = 0
Stupid me, i forgot to mention that i actually converted bl_objects to array
before that... but still that does not work. it compains that arrays used as
indices should be integers... but i can see that where returns a tuple...
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-user