Forums > Jitter

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

Dec 14 2011 | 2:23 am

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.

Dec 14 2011 | 2:28 am

jit.3m ??

Dec 14 2011 | 2:37 am

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.

Good luck.

Dec 15 2011 | 1:11 am


Viewing 4 posts - 1 through 4 (of 4 total)

Forums > Jitter