[Numpy-discussion] Help speeding up element-wise operations for video processing

David Huard david.huard@gmail....
Tue Sep 16 09:04:33 CDT 2008


Brendan,

Not sure if I understand correctly what you want, but ...

Numpy vector operations are performed in C, so there will be an iteration
over the array elements.

For parallel operations over all pixels, you'd need a package that talks to
your GPU, such as pyGPU.
I've never tried it and if you do, please report your experience, I'd be
very interested to hear about it.

HTH,

David




On Tue, Sep 16, 2008 at 4:50 AM, Stéfan van der Walt <stefan@sun.ac.za>wrote:

> Hi Brendan
>
> 2008/9/16 brendan simons <spam4bsimons@yahoo.ca>:
> > #interpolate the green pixels from the bayer filter image ain
> > g = greenMask * ain
> > gi = g[:-2, 1:-1].astype('uint16')
> > gi += g[2:, 1:-1]
> > gi += g[1:-1, :-2]
> > gi += g[1:-1, 2:]
> > gi /= 4
> > gi += g[1:-1, 1:-1]
> > return gi
>
> I may be completely off base here, but you should be able to do this
> *very* quickly using your GPU, or even just using OpenGL.  Otherwise,
> coding it up in ctypes is easy as well (I can send you a code snippet,
> if you need).
>
> > I do something similar for red and blue, then stack the interpolated red,
> > green and blue integers into an array of 24 bit integers and blit to the
> > screen.
> >
> > I was hoping that none of the lines would have to iterate over pixels,
> and
> > would instead do the adds and multiplies as single operations. Perhaps
> numpy
> > has to iterate when copying a subset of an array?  Is there a faster
> array
> > "crop" ?  Any hints as to how I might code this part up using ctypes?
>
> Have you tried formulating this as a convolution, and using
> scipy.signal's 2-d convolve or fftconvolve?
>
> Cheers
> Stéfan
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20080916/843997ad/attachment.html 


More information about the Numpy-discussion mailing list