title: Wrong center of mass using scipy ndimage.measurements.center_of_mass
body: <p>I am trying to find the centre of mass on binary images using <code>ndimage.measurements.center_of_mass</code> from the Scipy library. </p>
  
  <p>My code goes as follow:</p>
  
  <pre><code>def show_keypoints(image, key_point):
      plt.imshow(image, interpolation='nearest')
      plt.scatter(key_point[0],key_point[1], s=20, marker='.', c='lightgreen')
  
  
  #Loading the image (shape : (576,576) as np.array))
  img = load_img(path)
  centroid = scipy.ndimage.measurements.center_of_mass(img)
  
  fig = plt.figure()  
  ax = plt.subplot()
  ax.set_title('Label')
  show_keypoints(img, centroid)
  plt.show()   
  </code></pre>
  
  <p>obtain:</p>
  
  <p><a href="https://i.stack.imgur.com/IBAxD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IBAxD.png" alt="enter image description here"></a></p>
  
  <p>So I checked if I had the right image as input, it's correct, I checked if the image was binary using <code>np.unique(imgs[i])</code> got <code>(array([0, 1], dtype=uint8)</code>.</p>
  
  <p>I am not sure what's not right here.</p>
  
  <p>Does anyone has an idea?</p>
  
  <p>Regards,</p>