title: Get centroids from white ROIs - Opencv (Python)
body: <p>I'd want to get the centroids of several white regions and I'm trying with findContours(), then getting the moments and calculating the centroids. However, I'm not sure what it is stored in contours and how to do it well... </p>
  
  <p>This is the code </p>
  
  <pre><code># load the image
  image = cv2.imread('mask.png',0) # Black and white image
  
   contours, _, _ = cv2.findContours(image,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
  
  # Why only a row??
  cnt = contours[1]
  
  M = cv2.moments(cnt)
  print M
  
  cx = int(M['m10']/M['m00'])
  cy = int(M['m01']/M['m00'])
  
  print contours 
  </code></pre>
  
  <p>Any help would be appreciate! :)</p>