title: Incrementing a numpy 3-D array with repeating 2-D positions
body: <p>I have a 2-D numpy array as follows,</p>
  
  <pre><code>vol_coords = np.array([[  2,  68],
                         [ 79,  30],
                         [  2,  68],
                         [ 79,  30],
                         [ 79,  30],])
  </code></pre>
  
  <p>I would like to increment the positions given in the above array in a 3-D volume where the z position is fixed. Imagine it to be a slice of the volume in the x-y plane. </p>
  
  <pre><code> voxel_space = np.zeros((100, 240, 180))
  </code></pre>
  
  <p>The increment in the 3-D volume is equal to the number of times the position appears in the earlier array. Suppose I decide to increment the Oth Z position in the 3-D array, then the expected results are as below:</p>
  
  <pre><code>&gt;&gt; voxel_space[0, 2, 68]
  2.0
  &gt;&gt; voxel_space[0, 79, 30]
  3.0
  </code></pre>
  
  <p>I have been using the following approach,</p>
  
  <pre><code>voxel_space[0 , vol_coords[:, 0], vol_coords[:,1]]+=1
  </code></pre>
  
  <p>However the above approach always gives me a value of <code>1.0</code> and does not take into account repetitions in the <code>vol_coords</code> array. Could someone please tell me how I could solve this problem. I would prefer not using a for loop and iteratively solving the problem.</p>