title: Vectorized moving window on 2D array in numpy
body: <p>I am apply an operation on a moving window of constant size across a 2D array.  Is there an efficient vectorize-like operation I can implement to do this without looping in Python?  My current structure looks something like this</p>
  
  <pre><code> for i in range(1,xmax-1):
       for j in range(1,ymax-1):
          out[i][j] = f(in[i][j],in[i+1][j],in[i-1][j],in[i][j+1],in[i][j-1],...)
  </code></pre>
  
  <p>The comments that <em>eat</em> left in this question allude to the possibility of vectorizing this operation this, but without further details <a href="https://stackoverflow.com/questions/6877008/vectorized-indexing-slicing-in-numpy-scipy">vectorized indexing/slicing in numpy/scipy?</a> </p>