[SciPy-User] Convolving an ndarray by a function
Solbrig, Mr. Jeremy
Jeremy.Solbrig at nrlmry.navy.mil
Wed Sep 26 16:25:53 EDT 2012
Hi all,
I have run into a situation where I need to calculate the standard deviation for each NxM box within an ndarray. I am wondering if there is a function available that would allow me to convolve (may not be the correct word here) an ndarray by a function and return an array of the same size as the original array. Something like this:
>>> foo = np.arange(10000).reshape([100,100])
>>> stddev_arr = foo.funcconvolve([3, 3], np.std)
>>> stddev_arr.shape == foo.shape
True
Such that each point within stddev_arr is the standard deviation of a 3x3 box around each point in foo.
I'm sure I could code this in a loop, but I expect that there is a better solution.
Thanks for your help,
Jeremy
Jeremy Solbrig
NRL Monterey
jeremy.solbrig at nrlmry.navy.mil
(831) 656-4885
More information about the SciPy-User
mailing list