title: Is there shorthand for getting the center pixels of an image?
body: <p>Is there any indexing shorthand in numpy to get the center pixels of an image (or any ND array)?</p>
  
  <p>Example:</p>
  
  <pre><code>cutout = xc[xc.shape[0]/2-30:xc.shape[0]/2+30,xc.shape[1]/2-30:xc.shape[1]/2+30]
  </code></pre>
  
  <p>I could define a function</p>
  
  <pre><code>def get_center_pixels(arr, npix):
      slices = [slice(shape/2-npix,shape/2+npix) for shape in arr.shape]
      return arr[slices]
  
  cutout = get_center_pixels(xc,30)
  </code></pre>
  
  <p>Is there a better way or a built-in way to do this?</p>