[SciPy-user] can this be vectorized?

Robert Kern robert.kern@gmail....
Tue Jun 2 15:11:36 CDT 2009

On Tue, Jun 2, 2009 at 15:05, Ranjit Chacko <rjchacko@gmail.com> wrote:
> I have a square array A and I want to produce a second square array B of the
> same dimension where each element of B is the sum of a square neighborhood
> of each element of A. Is there a way to do this without loops in numpy, or
> do I have to use for loops?

scipy.ndimage.convolve() with a square array of 1s the size of the
desired neighborhood as the weights parameter.

Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco

More information about the SciPy-user mailing list