[SciPy-user] Array selection help
Stéfan van der Walt
Wed Feb 11 09:26:31 CST 2009
2009/2/11 Jose Luis Gomez Dans <email@example.com>:
>> 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.
Thanks, now I understand! In that case your for-loop should be fine
(I guess you won't have too many unique indices?).
More information about the SciPy-user