title: In Python: the center of mass of specific regions of values in a 2D numpy array
body: <p>I am working with a series of <code>numpy.ndarray</code> made of 101x101 values ranging 0.0 to 1.0. All arrays look like this:</p>
  
  <pre><code>array([[ 0.216,  0.24 ,  0.244, ...,  0.679,  0.684,  0.707],
         [ 0.23 ,  0.229,  0.238, ...,  0.675,  0.676,  0.695],
         [ 0.221,  0.238,  0.24 , ...,  0.669,  0.677,  0.684],
         ..., 
         [ 0.937,  0.925,  0.923, ...,  0.768,  0.754,  0.752],
         [ 0.937,  0.929,  0.923, ...,  0.737,  0.735,  0.741],
         [ 0.934,  0.932,  0.929, ...,  0.72 ,  0.717,  0.728]])
  </code></pre>
  
  <p>Now, say that I have a <code>threshold value=0.2</code>: how could I locate the "regions" of values within the matrix in such a way that, within them, the threshold is exceeded? In this case, I would be looking for regions which values are <code>&gt;=0.2</code>.</p>
  
  <p>In particular, I would like to:</p>
  
  <ol>
  <li>Count the number of regions that exceed the <code>threshold value</code>;</li>
  <li>Determine their <code>centers of mass</code>.</li>
  </ol>
  
  <p>I know that I can compute the latter by means of: <code>ndimage.measurements.center_of_mass()</code>, but I fail to see how it could be applied to just "regions" of a matrix rather than the whole thing.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Please consider that the "regions" I refer to have irregular shapes.</p>