Re: [Numpy-discussion] Numpy vs PIL in image statistics

2009-05-29 Thread Dag Sverre Seljebotn
cp wrote: >> I don't know anything about PIL and its implementation, but I would not >> be surprised if the cost is mostly accessing items which are not >> contiguous in memory and bounds checking ( to check where you are in the >> subimage). Conditional inside loops often kills performances, and t

Re: [Numpy-discussion] Numpy vs PIL in image statistics

2009-05-28 Thread cp
> I don't know anything about PIL and its implementation, but I would not > be surprised if the cost is mostly accessing items which are not > contiguous in memory and bounds checking ( to check where you are in the > subimage). Conditional inside loops often kills performances, and the > actual co

Re: [Numpy-discussion] Numpy vs PIL in image statistics

2009-05-28 Thread David Cournapeau
cp wrote: >>> The image I tested initially is 2000x2000 RGB tif ~11mb in size. >>> > I continued testing, with the initial PIL approach > and 3 alternative numpy scripts: > > #Script 1 - indexing > for i in range(10): > imarr[:,:,0].mean() > imarr[:,:,1].mean() > imarr[:,:,2].mea

Re: [Numpy-discussion] Numpy vs PIL in image statistics

2009-05-28 Thread cp
>> The image I tested initially is 2000x2000 RGB tif ~11mb in size. I continued testing, with the initial PIL approach and 3 alternative numpy scripts: #Script 1 - indexing for i in range(10): imarr[:,:,0].mean() imarr[:,:,1].mean() imarr[:,:,2].mean() #Script 2 - slicing for i in ran

Re: [Numpy-discussion] Numpy vs PIL in image statistics

2009-05-27 Thread Robert Kern
On Wed, May 27, 2009 at 10:33, cp wrote: > Testing the PIL vs numpy in calculating the mean value of each color channel > of > an image I timed the following. > > impil = Image.open("10.tif") > imnum = asarray(impil) > > #in PIL > for i in range(1,10): >    stats = ImageStat.Stat(impil) >    stat

[Numpy-discussion] Numpy vs PIL in image statistics

2009-05-27 Thread cp
Testing the PIL vs numpy in calculating the mean value of each color channel of an image I timed the following. impil = Image.open("10.tif") imnum = asarray(impil) #in PIL for i in range(1,10): stats = ImageStat.Stat(impil) stats.mean # for numpy for i in range(1,10): imnum.resha