Ask Your Question

Revision history [back]

I would suggest running a 4 nested loops on x,y, width, height and using the function countNonZero to count the number of white pixels. You can also take the negative image and use countNonZero to count the number of black pixels.

countNonZero:

http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#countnonzero

negative image:

http://www.programming-techniques.com/2013/01/producing-nagative-of-grayscale-image-c.html

I would suggest running a 4 nested loops on x,y, width, height and using the function countNonZero to count the number of white pixels. You can also take the negative image and use countNonZero to count the number of black pixels.

countNonZero:

http://docs.opencv.org/modules/core/doc/operations_on_arrays.html#countnonzero

negative image:

http://www.programming-techniques.com/2013/01/producing-nagative-of-grayscale-image-c.html