[Numpy-discussion] Help speeding up element-wise operations for video processing
Tue Sep 16 09:04:33 CDT 2008
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.
On Tue, Sep 16, 2008 at 4:50 AM, Stéfan van der Walt <email@example.com>wrote:
> Hi Brendan
> 2008/9/16 brendan simons <firstname.lastname@example.org>:
> > #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,
> > would instead do the adds and multiplies as single operations. Perhaps
> > has to iterate when copying a subset of an array? Is there a faster
> > "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?
> Numpy-discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Numpy-discussion