title: Variable area threshold for identifying objects - python
body: <p>I have an array which contains information of the size and location a series of shapes: where the array is zero, there are no shapes, where the array is not zero there is a shape. Different shapes are separated by  zeros - so that if you were to plot every point in the array, you would see a map of the various shapes. I hope that makes sense, if not here is an example array containing 4 different shapes:</p>
  
  <pre><code>np.array([[0, 0, 0, 1, 0, 0, 0],
            [0, 0, 0, 0, 0, 0, 0],
            [1, 1, 0, 0, 1, 0, 0],
            [1, 1, 0, 0, 0, 1, 1],
            [0, 0, 0, 0, 0, 1, 1],
            [3, 5, 2, 0, 0, 0, 0]])
  </code></pre>
  
  <p>I need to count and identify these shapes but I only want to include the ones with an area above a certain threshold. 
  I would like the area threshold to be 1/15 of the area of the largest shape in the field. (In the above example, the largest area would be 5.</p>
  
  <p>The question is: How can I find (using python) the area of the maximum shape in the field without individually identifying each shape? </p>
  
  <h2>Edit</h2>
  
  <p>To clarify what I mean by the 'shapes', the following code plots an image of the array, which shows 4 distinct objects: </p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  
  a = np.array([[0, 0, 0, 1, 0, 0, 0],
                [0, 0, 0, 0, 0, 0, 0],
                [1, 1, 0, 0, 1, 0, 0],
                [1, 1, 0, 0, 0, 1, 1],
                [0, 0, 0, 0, 0, 1, 1],
                [1, 1, 1, 0, 0, 0, 0]])
  ind = np.nonzero(arr)
  x = ind[0]
  y = ind[1]
  plt.imshow(arr)
  plt.show()
  </code></pre>