Ask Your Question

Revision history [back]

Consider using k-means clustering to split the pixels of the image into distinct clusters based on color. In this case, you'd probably want to use k=3, i.e., 3 clusters (one for the white background, one for the brown, and one for the yellow). Then it would simply be a matter of counting the number of pixels belonging to each cluster label.

OpenCV seems to have a k-means method, though I'm not familiar with it. You may want to check out the scikit-learn k-means method instead.