I have multiple pictures, each of which has an object with its background removed. The pictures are 500x400 pixels in size.
I am looking for a way to programmatically (preferably using python) calculate the total number of pixels of the image inside the picture (inside the space without the background).
I used the PIL package in Python to get the dimensions of the image object, as follows:
print(image.size)
This command successfully produced the dimensions of the entire picture (500x400 pixels) but not the dimensions of the object of interest inside the picture.
Does anyone know how to calculate the dimensions of an object inside a picture using python? An example of a picture is embedded below.