 <p>By count each color pixels you get the area, if you already label your data as following:</p> <pre><code>data = np.array([[0,0,1,1,1], [2,2,1,1,1], [2,3,3,3,3], [2,4,4,3,3]]) </code></pre> <p>than you can use numpy.bincount() to count each label:</p> <pre><code>print numpy.bincount(data.ravel()) </code></pre> <p>the output is :</p> <pre><code>array([2, 6, 4, 6, 2]) </code></pre> <p>which means there are two 0, six 1, four 2, six 3, and two 4.</p>