Ask Your Question

Revision history [back]

You can use the function cv::countNonZero to count the number of black pixels. If your image only contains black and white pixels, the number of white pixels will be: (image_width * image_height) - black_pixel_count