Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to find R,G,B percentage in an image

hi, i want to find red green and blue percentage in an image. i used the following code which shows 0%age for the red. help to improve my code.

below is code :

vector<mat> channels; split(hsv_img,channels);

Mat red, blue, green; inRange(channels[0], Scalar(0), Scalar(10), red); // red // ... do the same for blue, green, etc only changing the Scalar values and the Mat

double image_size = hsv_img.cols*hsv_img.rows; double red_percent = ((double) cv::countNonZero(red))/image_size;

what shoud i change in scalar to have green and blue value.

thanks !!

click to hide/show revision 2
No.2 Revision

How to find R,G,B percentage in an image

hi, i want to find red green and blue percentage in an image. i used the following code which shows 0%age for the red. help to improve my code.

below is code :

vector<mat>

vector<Mat> channels;
split(hsv_img,channels);

split(hsv_img,channels);

Mat red, blue, green; inRange(channels[0], Scalar(0), Scalar(10), red); // red // ... do the same for blue, green, etc only changing the Scalar values and the Mat

Mat

double image_size = hsv_img.cols*hsv_img.rows; double red_percent = ((double) cv::countNonZero(red))/image_size;

cv::countNonZero(red))/image_size;

what shoud i change in scalar to have green and blue value.

thanks !!

How to find R,G,B percentage in an image

hi, i want to find red green and blue percentage in an image. i used the following code which shows 0%age for the red. help to improve my code.

below is code :

vector<Mat> channels;
split(hsv_img,channels);

Mat red, blue, green;
inRange(channels[0], Scalar(0), Scalar(10), red); // red
// ... do the same for blue, green, etc only changing the Scalar values and the Mat

double image_size = hsv_img.cols*hsv_img.rows;
double red_percent = ((double) cv::countNonZero(red))/image_size;

what shoud i change in scalar to have green and blue value.

thanks !!

click to hide/show revision 4
retagged

How to find R,G,B percentage in an image

hi, i want to find red green and blue percentage in an image. i used the following code which shows 0%age for the red. help to improve my code.

below is code :

vector<Mat> channels;
split(hsv_img,channels);

Mat red, blue, green;
inRange(channels[0], Scalar(0), Scalar(10), red); // red
// ... do the same for blue, green, etc only changing the Scalar values and the Mat

double image_size = hsv_img.cols*hsv_img.rows;
double red_percent = ((double) cv::countNonZero(red))/image_size;

what shoud i change in scalar to have green and blue value.

thanks !!