## quick way to measure how much white there is in a black and white matrix?

Dec 14, 2011 at 2:23am

# quick way to measure how much white there is in a black and white matrix?

Is there a fast way to do this that isn’t processor intensive? I just want a proportion. I’m using blob tracking, I want to know how much space is being occupied. I figure I can use jit.iter but that seems intensive for the CPU.

#60661
Dec 14, 2011 at 2:28am

jit.3m ??

#218329
Dec 14, 2011 at 2:37am

Here’s a quote from the description of HoldStill (Jitter Recipe #32 – book 3)

The jit.3m gives the mean value of all of the cells in a matrix. If you remember your arithmetic, you will know that the mean is derived by adding all elements together and then dividing by the number of elements. We take the inverse approach to calculate the total number of white pixels in our image.

This is done by first multiplying the mean output by 327,200, which is the total number of pixels in a 640×480 matrix. Since the value of white in char data is 255, we must then divide by 255 to get the number of white pixels.

http://cycling74.com/2010/09/13/jitter-recipes-book-3/

Good luck.

#218330
Dec 15, 2011 at 1:11am

Thanks.

#218331

You must be logged in to reply to this topic.