I have a binary image. Within a certain region of interest, I need to count the number of black pixels. There is always the way of looping through the pixels and counting them, but I’m looking for a more efficient method as I need to do it real-time.
I found a way to count the number of nonzero pixels(using cvCountNonZero()). Is there any such equivalent function for counting zero pixels (there doesn’t seem to be as far as I’ve seen)? If not, what is the most efficient way to count the black pixels?
I believe the number of zero pixels could be seen as: