title: Why IndexError: index 1 is out of bounds for axis 0 with size 1
body: <p>The following code is used to find key points of an image given the location x y coordinates with variable "locs".tp=256,r=180,c=240. During debugging I am receiving an Index error for the line  <strong><em>desc[idx-1, ] = tmp</em></strong>. </p>
  
  <pre><code>tp = compareX.shape[0]
  desc = np.zeros((1, tp))
  r = im.shape[0]
  c = im.shape[1]
  idx = 1
  new_locs = np.zeros((locs.shape))
  
  
  for i in range(1, locs.shape[0]):
  
      x = math.floor(locs[i - 1, 0])  # keypoint x coordinate
      y = math.floor(locs[i - 1, 1])  # keypoint y coordinate
      #non-maximum suppression 
      if (x - 4) &lt; 1 or (y - 4) &lt; 1 or (x + 4) &gt; c or (y + 4) &gt; r:
          continue
  
      #save passing coordinates
      new_locs[idx - 1,] = np.array([x, y])
  
      #Calculate BRIEF descriptor 
      tmp = np.zeros((1, tp))
  
      x = x-4
      y = y-4
      for j in range(1, tp):
          ax = x + math.floor((compareX[j-1]-1)/patchWidth)
          ay = y + ((compareX[j-1]-1) % patchWidth)
          bx = x + math.floor((compareY[j-1] - 1) / patchWidth)
          by = y + ((compareY[j-1] - 1) % patchWidth)
          if (im[ay, ax] &lt; im[by, bx]).all():
              tmp[0, j-1] = 1
      ***desc[idx-1, ] = tmp***
      idx = idx + 1
  locs = new_locs
  return locs, desc
  </code></pre>