1 | initial version |
If image is RGB try cv2.split to split into a single-channel array, and then count non-zero pixels on Blue channel.
2 | No.2 Revision |
If image is RGB try cv2.split to I do not know how things work in python, but in c++ you can do the following
cv::Mat bgrImage = cv::imread("test.jpg");
std::vector<cv::Mat> bgrChannels;
cv::split(bgrImage, bgrChannels); // split multi-channels into a single-channel array, and then single-channel
int blue = cv::countNonZero(bgrChannels[0]) // count the non-zero pixels on Blue channel.channel
cv::split wrap for python cv2.split()