Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The program to count number of white and black pixels in a binary image is working.Here I paste the code i used.Please help me with a solution.

int count_white=0; int count_black=0;

for (int y = 0; y < image.rows; y++) { for (int x = 0; x < image.cols; x++) { if (image.at<cv::vec3b>(y, x) == cv::Vec3b(255, 255, 255)) { count_white++; } else if (image.at<cv::vec3b>(y, x) == cv::Vec3b(0, 0, 0)) { count_black++; } } }

click to hide/show revision 2
No.2 Revision

updated 2017-03-21 03:09:46 -0600

berak gravatar image

The program to count number of white and black pixels in a binary image is working.Here I paste the code i used.Please help me with a solution.

int count_white=0;
int count_black=0;

count_black=0; for (int y = 0; y < image.rows; y++) { for (int x = 0; x < image.cols; x++) { if (image.at<cv::vec3b>(y, (image.at<cv::Vec3b>(y, x) == cv::Vec3b(255, 255, 255)) { count_white++; } else if (image.at<cv::vec3b>(y, (image.at<cv::Vec3b>(y, x) == cv::Vec3b(0, 0, 0)) { count_black++; } } }

}

The program to count number of white and black pixels in a binary image is not working.Here I paste the code i used.Please help me with a solution.

int count_white=0; int count_black=0; count_black=0;

for (int y = 0; y < image.rows; y++) { for (int x = 0; x < image.cols; x++) { if (image.at<cv::Vec3b>(y, (image.at<cv::vec3b>(y, x) == cv::Vec3b(255, 255, 255)) { count_white++; } else if (image.at<cv::Vec3b>(y, (image.at<cv::vec3b>(y, x) == cv::Vec3b(0, 0, 0)) { count_black++; } } }

}

click to hide/show revision 4
No.4 Revision

updated 2017-03-21 03:10:19 -0600

berak gravatar image

The program to count number of white and black pixels in a binary image is not working.Here I paste the code i used.Please help me with a solution.

int count_white=0;
int count_black=0;

count_black=0; for (int y = 0; y < image.rows; y++) { for (int x = 0; x < image.cols; x++) { if (image.at<cv::vec3b>(y, (image.at<cv::Vec3b>(y, x) == cv::Vec3b(255, 255, 255)) { count_white++; } else if (image.at<cv::vec3b>(y, (image.at<cv::Vec3b>(y, x) == cv::Vec3b(0, 0, 0)) { count_black++; } } }

}