Help, Image Filters with numpy

Travis Oliphant olipt at mayo.edu
Fri Jun 2 16:46:52 EDT 2000


> i have some image data, greyscale, and i'd like to do
> some simple filter work on it. i'm trying to think of
> a "most optimized" way to get this done. i'm not sure
> about all the tools that numerical python gives me, so
> i thought i'd ask to see if parts of this are already
> taken care of.
> 
> say i define a quick soften filter...
> 
> soften = array([[1,2,1], [2,4,2], [1,2,1]])
> 
> how can i quickly/easily apply this to my image
> which is stored in another array? i've been hunting
> examples that would do this for me, but no luck


Charles Waldman already told you this is called convolution and that it
can be efficiently performed using FFT's if the kernel sizes are large. 

He did not tell you that I have a general convolution routine that will do
what you want in the package signaltools.  I use it constantly for just
this kind of operation.  signaltools is available at
http://oliphant.netpedial.net

The routine is quite general and will do N-dimensional convolution with
arbitrary kernels for arbitrary data types (even object types).  For your
purposes you would use it like this:

output = signaltools.convolveND(someimage, soften, 'same')

The code is written in C and is quite fast.  The 'same' is to return an
image with the same size.

Good luck,

Travis






More information about the Python-list mailing list