[SciPy-user] Array selection help
Jose Luis Gomez Dans
josegomez@gmx....
Wed Feb 11 09:03:15 CST 2009
> >> scipy.ndimage.mean(arr2, labels=arr1, index=np.unique(arr1))
> >
> > True. The question is, how do I get the output of your code back into my
> > original array? Presumably, there's another function that does that
> quickly?
>
> It is already in an array, so I'm not sure I understand. Maybe you mean
>
> out[:] = scipy.ndimage.mean(...) ?
Sorry, I was clumsy with my wording. What I meant is how to put together the results, so that I have a 2D array where the value of each element is the value that corresponds to the mean of the corresponding label. So if arr1[100,100] = 4 (say), and after running the mean of arr2 for elements that in arr1 are labeled as 4, the mean value is 2.3, I'd like to have an array (out, out.shape == arr1.shape) where the values of elements of out that share a common label are given the mean value (2.3 for those labeled as 4 in my previous example).
In essence, I want to have an array where each element is the mean value for its corresponding class.
many thanks!
Jose
--
Jetzt 1 Monat kostenlos! GMX FreeDSL - Telefonanschluss + DSL
für nur 17,95 Euro/mtl.!* http://dsl.gmx.de/?ac=OM.AD.PD003K11308T4569a
More information about the SciPy-user
mailing list