[Numpy-discussion] Counting the Colors of RGB-Image

apo@pda... apo@pda...
Sun Jan 15 09:45:48 CST 2012


An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20120115/0310a1ac/attachment.html 
-------------- next part --------------

Counting the Colors of RGB-Image, 
nameit im0 with im0.shape = 2500,3500,3
with this code:

tab0 = zeros( (256,256,256) , dtype=int)
tt = im0.view()
tt.shape = -1,3
for r,g,b in tt:
 tab0[r,g,b] += 1

Question:

Is there a faster way in numpy to get this result?


MfG elodw






More information about the NumPy-Discussion mailing list