[SciPy-user] Array selection help

Stéfan van der Walt stefan@sun.ac...
Wed Feb 11 01:39:21 CST 2009

2009/2/11 Jose Luis Gomez Dans <josegomez@gmx.net>:
> Going back to my example, my labels grid is arr1, so I just have to do, eg:
> for i in numpy.unique ( arr1 ):
>  print i, scipy.ndimage.mean ( arr2, labels=arr1, index=i )

Ndimage can also do the for loop:

scipy.ndimage.mean(arr2, labels=arr1, index=np.unique(arr1))


More information about the SciPy-user mailing list