[Numpy-discussion] the neighbourhood of each element of an array

2007-02-23 Thread joris
Hi, Given a (possibly masked) 2d array x, is there a fast(er) way in Numpy to obtain the same result as the following few lines? d = 1 # neighbourhood 'radius' Nrow = x.shape[0] Ncol = x.shape[1] y = array([[x[i-d:i+d+1,j-d:j+d+1].ravel() for j in

Re: [Numpy-discussion] the neighbourhood of each element of an array

2007-02-23 Thread Bryan Cole
On Fri, 2007-02-23 at 17:38 +0100, [EMAIL PROTECTED] wrote: Hi, Given a (possibly masked) 2d array x, is there a fast(er) way in Numpy to obtain the same result as the following few lines? d = 1 # neighbourhood 'radius' Nrow = x.shape[0] Ncol =

Re: [Numpy-discussion] the neighbourhood of each element of an array

2007-02-23 Thread Zachary Pincus
Scipy's ndimage module has a function that takes a generic callback and calls it with the values of each neighborhood (of a given size, and optionally with a particular mask footprint) centered on each array element. That function handles boundary conditions, etc nicely. Unfortunately, I'm

Re: [Numpy-discussion] the neighbourhood of each element of an array

2007-02-23 Thread Pierre GM
On Friday 23 February 2007 14:53:05 Zachary Pincus wrote: Scipy's ndimage module has a function that takes a generic callback and calls it with the values of each neighborhood (of a given size, and optionally with a particular mask footprint) centered on each array element. That function