[Numpy-discussion] Finding Unique Pixel Values
Fri Jul 23 02:13:18 CDT 2010
Ian Mallett wrote:
> To the second, actually, I need to increment the number of times the
> index is there. For example, if b=[1,5,6,6,6,9], then a[6-1] would have
> to be incremented by +3 = +1+1+1. I tried simply a[b-1]+=1, but it
> seems to only increment values once, even if there are more than one
> occurrence of the index in "b". What to do about that?
Is this what you mean?
>>> numpy.bincount( [1,5,6,6,6,9] )
array([0, 1, 0, 0, 0, 1, 3, 0, 0, 1])
More information about the NumPy-Discussion