Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Wouldn't this work?

int count_black = cv::countNonZero(mask == 0);
int count_white = cv::countNonZero(mask == 255);

Wouldn't this work?

cv::Mat masked;
image.copyTo(masked, mask);
int count_black = cv::countNonZero(mask cv::countNonZero(masked == 0);
int count_white = cv::countNonZero(mask cv::countNonZero(masked == 255);