[Numpy-discussion] Fast histogram
Zachary Pincus
zachary.pincus at yale.edu
Thu Apr 17 13:09:13 EDT 2008
>> But even if indices = array, one still needs to do something like:
>> for index in indices: histogram[index] += 1
>>
>> Which is slow in python and fast in C.
>>
>>
> I thought of a broadcasting approach... what are the chances that a
> simple
>
> bins[:] = 0
> bins[ img.flat ] += 1
That doesn't work cumulatively, it seems. Some bins get a value of
'1', but it never gets incremented past that.
It was worth a try, though... in some cases in-place updating seems to
work this way (which is usually a source of confusion on this list,
not the desired result!)
Zach
More information about the NumPy-Discussion
mailing list