title: Slicing a numpy image array into blocks
body: <p>I'm doing image processing for object detection using python. I need to divide my image into all possible blocks. For example given this toy image:</p>
  
  <pre><code>x = np.arange(25)
  x = x.reshape((5, 5))
  
  [[ 0  1  2  3  4]
   [ 5  6  7  8  9]
   [10 11 12 13 14]
   [15 16 17 18 19]
   [20 21 22 23 24]]
  </code></pre>
  
  <p>I want to retrieve all possible blocks of a given size, for example the 2x2 blocks are:</p>
  
  <pre><code>[[0 1]
   [5 6]]
  [[1 2]
   [6 7]]
  </code></pre>
  
  <p>.. and so on. How can I do this?</p>