[Numpy-discussion] convolve2d

Todd Miller jmiller at stsci.edu
Tue Jun 22 11:09:55 CDT 2004


On Tue, 2004-06-22 at 11:51, Michel Sanner wrote:
> Hello,
> 
> I started using numarray for doing 2D convolutions on images.  I noticed 
> that
> 
> import numarray.examples.convolve.high_level as convolve
> convolve.Convolve2d(kernel, in, out)
> 
> only works on square images.  For images that are not square I get lots 
> of noise in the background.

I looked at the code and couldn't find any row/column typos.  In theory,
Convolve2d works for non-square arrays.

What do kernel.info() and data.info() say?

> Also I was wondering is using the high_level API is most efficient?  

For CPU, my guess is yes.  The point access macros and functions are
definitely slower than the high level API in any scenario where you're
not running out of memory.  The 1D API improves space usage but is less
efficient in time.  The Numeric compatible API is layered over the high
level API.

> Currently my image is a Numeric
> array (grabbed from the OpenGL frame buffer) which I convert to a 
> numarray to do the convolution and back to a Numeric array.  

It's also possible something is happening during this conversion.  It'd
be good to round-trip the Numeric array and make sure the end product
looks like the original.

> In the future I hope to completely replace Numeric by numarray.

Great!

Regards,
Todd





More information about the Numpy-discussion mailing list