1 | initial version |
Wouldn't this work?
int count_black = cv::countNonZero(mask == 0);
int count_white = cv::countNonZero(mask == 255);
2 | Corrected code |
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);