title: Python - Efficient way to find the largest area of a specific value in a 2D numpy array
body: <p>I have a 2D numpy array where some values are zero, and some are not. I'm trying to find an efficient way to find the biggest clump of zeros in the array (by returning the number of zeros, as well as a rough idea of where the center is)</p>
  
  <p>For example in this array, I would like to find the clump of 9, with the center of (3,4):</p>
  
  <pre><code>[[ 1, 1, 1, 0, 0 ],
   [ 1, 0, 1, 1, 0 ],
   [ 1, 1, 1, 1, 1 ],
   [ 1, 1, 0, 0, 0 ],
   [ 1, 1, 0, 0, 0 ],
   [ 1, 1, 0, 0, 0 ]]
  </code></pre>
  
  <p>Is there a nice vectorized way to accomplish something like this in numpy or scipy?</p>
  
  <p>The clumps will be roughly circular in shape, and have no holes in them.</p>
  
  <p><a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.measurements.label.html">ndimage.label()</a> from scipy does something close to this, but isn't quite what I'm after. I have a feeling <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html">numpy.where()</a> and <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.diff.html">numpy.diff()</a> could be helpful, but not sure how to efficiently use them to solve this problem.</p>