Count gray and black pixels from a c++ drawing

Asked

Viewed 89 times

0

I have a drawing painted with felt-tip pens and scanned, only seven colors are present: green, blue, black, gray, violet, orange and red I need to know the percentage of color used.

I can’t tell the gray pixels from the black ones, they might help ?

I got the feed -> srcimage

Mat srcimage, hsvimage, HSV_threshold, thres_dst;
srcimage = imread("teste.jpg", IMREAD_REDUCED_COLOR_4);

cvtColor(srcimage , hsvimage, COLOR_BGR2HSV);
Mat HSV = hsvimage.clone();
int low_H = 0, low_S = 0, low_V = 0;
int high_H = 0, high_S = 0, high_V = 0;


low_H = 75, low_S = 6, low_V = 200;
high_H = 120, high_S = 48, high_V = 211;
inRange(HSV, Scalar(low_H, low_S, low_V), Scalar(high_H, high_S, high_V), HSV_threshold);

Mat binfinal, binfinalsrc;
bitwise_and(HSV, HSV, binfinal, HSV_threshold);
bitwise_and(srcimagetemp, srcimagetemp, binfinalsrc, HSV_threshold);
  • from RGB(0,0,0) black to RGB(245,245,245) grey. So you need a function that reads the RGB components of each color.

  • suggest using the image in rgb ? the problem and the variation is huge and all the ranges are valid

  • the objective and count all colors including black and grey only which have values in the same range, thanks

  • for example H=101 S=10 V= 211 satisfies both colors

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.