White Pixel Count

General discussion about topics related to OpenMV.
Tim H
Posts: 5
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: 2282
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,
Tim H
Posts: 5
Joined: Tue Apr 24, 2018 11:21 am

Re: White Pixel Count

Postby Tim H » Thu May 24, 2018 3:24 am

Yeah perfect works fine. Thats a smart idea. With the find_blobs function.
User avatar
kwagyeman
Posts: 2282
Joined: Sun May 24, 2015 2:10 pm

Re: White Pixel Count

Postby kwagyeman » Thu May 24, 2018 1:42 pm

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.
Nyamekye,

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 7 guests