White Pixel Count

General discussion about topics related to OpenMV.
Tim H
Posts: 1
Joined: Tue Apr 24, 2018 11:21 am

White Pixel Count

Postby Tim H » Wed May 02, 2018 10:02 am

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
User avatar
kwagyeman
Posts: 1746
Joined: Sun May 24, 2015 2:10 pm

Re: White Pixel Count

Postby kwagyeman » Wed May 02, 2018 11:16 pm

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

Code: Select all

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

Code: Select all

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

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest