title: Find a 3x3 sliding window over an image
body: <p>I have an image.</p>
  
  <p>I want to obtain a 3x3 window (neighbouring pixels) for every pixel in the image.</p>
  
  <p>I have this Python code:</p>
  
  <pre><code>for x in range(2,r-1,1):
      for y in range(2,c-1,1):
          mask5=numpy.array([cv.Get2D(copy_img,x-1,y-1),cv.Get2D(copy_img,x-1,y),cv.Get2D(copy_img,x-1,y+1),cv.Get2D(copy_img,x,y-1),cv.Get2D(copy_img,x,y),cv.Get2D(copy_img,x,y+1),cv.Get2D(copy_img,x+1,y-1),cv.Get2D(copy_img,x+1,y),cv.Get2D(copy_img,x+1,y+1)])
          cent=[cv.Get2D(copy_img,x,y)]
  </code></pre>
  
  <p>mask5 is the 3x3 window. cent is the center pixel.</p>
  
  <p>Is there a more efficient way to do this - i.e. using maps, iterators - anything but the two nested loops I've used?</p>