[SciPy-User] Convolving an ndarray by a function
Solbrig, Mr. Jeremy
Wed Sep 26 15:25:53 CDT 2012
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
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,
More information about the SciPy-User