Re: [Numpy-discussion] fast grayscale conversion

2011-06-20 Thread Christopher Barker
Alex Flint wrote: > Thanks, that's helpful. I'm now getting comparable times on a different > machine, it must be something else slowing down my machine more > generally, not just numpy. you also might want to get a bit fancier than simply scaling linearly R,G, and B don't necessarily all contr

Re: [Numpy-discussion] fast grayscale conversion

2011-06-20 Thread Alex Flint
Thanks, that's helpful. I'm now getting comparable times on a different machine, it must be something else slowing down my machine more generally, not just numpy. On Mon, Jun 20, 2011 at 5:11 PM, Eric Firing wrote: > On 06/20/2011 10:41 AM, Zachary Pincus wrote: > > You could try: > > src_mono =

Re: [Numpy-discussion] fast grayscale conversion

2011-06-20 Thread Eric Firing
On 06/20/2011 10:41 AM, Zachary Pincus wrote: > You could try: > src_mono = src_rgb.astype(float).sum(axis=-1) / 3. > > But that speed does seem slow. Here are the relevant timings on my machine (a > recent MacBook Pro) for a 3.1-megapixel-size array: > In [16]: a = numpy.empty((2048, 1536, 3), dt

Re: [Numpy-discussion] fast grayscale conversion

2011-06-20 Thread Zachary Pincus
You could try: src_mono = src_rgb.astype(float).sum(axis=-1) / 3. But that speed does seem slow. Here are the relevant timings on my machine (a recent MacBook Pro) for a 3.1-megapixel-size array: In [16]: a = numpy.empty((2048, 1536, 3), dtype=numpy.uint8) In [17]: timeit numpy.dot(a.astype(floa

[Numpy-discussion] fast grayscale conversion

2011-06-20 Thread Alex Flint
At the moment I'm using numpy.dot to convert a WxHx3 RGB image to a grayscale image: src_mono = np.dot(src_rgb.astype(np.float), np.ones(3)/3.); This seems quite slow though (several seconds for a 3 megapixel image) - is there a more specialized routine better suited to this? Cheers, Alex __