White Pixel Count

I have a Project at the moment while i want to count the amount of White Pixels in a Picture. I found nothing in the Forum and the Helps where i can see more Deatails of a Picture.
Is there any Solution to get a Integer number of how many Pixel are white in the Pixture and how many aren’t?

Best Regards

Tim Hochstein

Yes, use find_blobs(), set the color thresholds to pure white. Then sum up all the pixels() values from each blob returned:

count = sum(map(lambda x: x.pixels(), img.find_blobs([(100, 100)])))

For RGB565

count = sum(map(lambda x: x.pixels(), img.find_blobs([(255, 255)])))

For GRAYSCALE

Yeah perfect works fine. Thats a smart idea. With the find_blobs function.

Note find_blobs() expects a min blob size and area and will filter out white pixel outlier blobs. If you want all pixels then you need to tweak the parameters.