On Fri, Jul 23, 2010 at 12:13 AM, Jon Wright <[email protected]> wrote: > 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]) > Well, I've implemented it thusly:
pixel_data = np.cast['int16'](255.0*glReadPixels(0,0,patch_view.width,patch_view.height,GL_RGB,GL_FLOAT)).reshape((-1,3)) pixel_data = np.dot(pixel_data,np.array([65025,255,1])) count = np.bincount(pixel_data)[1:] self.visibility[poly1num][0:count.shape[0]] += count And it works! Thanks everyone! Ian
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
