title: Add Offset to Indices of Numpy Array
body: <p>Following up to this question (and jorgeca's answer): 
  <a href="https://stackoverflow.com/questions/16774148/fast-way-to-slice-image-into-overlapping-patches-and-merge-patches-to-image">Fast Way to slice image into overlapping patches and merge patches to image</a> I want to add an offset to the indices of the patchified array, i.e:</p>
  
  <pre><code>A = np.arange(W*H).reshape(H,W)
  P = patchify(A,(X,Y)) 
  </code></pre>
  
  <p>Assuming X,Y are odd numbers, the size of P will be equal to W-X+1,H-Y+1, hence the pixel centered in P[0,0] will actually correspond to A[(Y-1)/2,(X-1)/2]. </p>
  
  <p>Is there any way I can offset (without copying any data) the indices of P to have perfect correspondence?</p>
  
  <p>For reference, here is the existing patchify function:</p>
  
  <pre><code>def patchify(img, patch_shape):
      img = np.ascontiguousarray(img)  # won't make a copy if not needed
      X, Y = img.shape
      x, y = patch_shape
      shape = ((X-x+1), (Y-y+1), x, y) # number of patches, patch_shape
      # The right strides can be thought by:
      # 1) Thinking of `img` as a chunk of memory in C order
      # 2) Asking how many items through that chunk of memory are needed when indices
      #    i,j,k,l are incremented by one
      strides = img.itemsize*np.array([Y, 1, Y, 1])
      return np.lib.stride_tricks.as_strided(img, shape=shape, strides=strides)
  </code></pre>