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

elodw apo@pdauf...
Mon Jan 23 13:40:21 CST 2012


  Am 23.01.2012 18:17, schrieb Chris Barker:
> On Wed, Jan 18, 2012 at 1:26 AM,<apo@pdauf.de>  wrote:
>> Your ideas are very helpfull and the code is very fast.
> I'm curios -- a number of ideas were floated here -- what did you end up using?
>
> -Chris
>
>
I'am sorry but  when i see the code of Torgil Svenson,
I think, "the game is over".

I use the follow. code:

t0=clock()

tt = n_im2.view()
tt.shape = -1,3
ifl = tt[...,0].astype(np.int)*256*256 + tt[...,1].astype(np.int)*256 + 
tt[...,2].astype(np.int)
colors, inv = np.unique(ifl,return_inverse=True)

zus = np.array([colors[-1]+1])
colplus = np.hstack((colors,zus))
ccnt = np.histogram(ifl,colplus)[0]

t1=clock()
print (t1-t0)
t0=t1


> --
>
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> Chris.Barker@noaa.gov
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion



More information about the NumPy-Discussion mailing list