Search code examples
pythonopencvimage-processingareamahotas

How can one compute and find the distribution of the areas of the objects in an image with Python?


I'd like to get the areas in pixels and the distributions of the different black objects in this image. I assume that with python (openCV or mahotas) it's possible to do it, but I don't know how.

enter image description here Can you help me ?


Solution

  • I'd use scikit-image. It looks like a binary image (0s and 1s) to me, so you could use regionprops function to get a list of regionprops objects.

    Regionprops ignores 0s (which is black in your case), so you might need to invert the image.