I have made a threshold in the image. Then I want to get the value of the image (black and white). I've tried using frame_hsv.at<Vec3b>(x, y)
but it can't. Is there another way to do it?
Threshold result:
I did a threshold to detect objects based on color.
My code :
Mat frame, frame_HSV, frame_gr, frame_wh, frame_out, img_final,
frame_mask;
const double PI = 3.14159265;
int main(int argc, char* argv[])
{
frame = imread("dasar/vlcsnap-error067.png");
cvtColor(frame, frame_HSV, COLOR_BGR2HSV);
inRange(frame_HSV, Scalar(44, 65, 97), Scalar(90, 196, 239), frame_gr);
Mat el_dilate = getStructuringElement(MORPH_ELLIPSE, Size(10, 10));
dilate(frame_gr, frame_gr, el_dilate);
inRange(frame_HSV, Scalar(5, 0, 192), Scalar(70, 73, 255), frame_wh);
frame_wh.copyTo(frame_out, frame_gr);
frame.copyTo(frame_mask, frame_gr);
imshow("GREEN (MASK)", frame_gr);
imshow("WHITE (OBJECT)", frame_wh);
imshow("MASK + OBJECT", frame_out);
imshow("ORIGINAL", frame);
imshow("MASK + ORIGINAL", frame_mask);
waitKey(0);
}
If possible, I also want to read the color values in the masking image (black and color).
Masking image: