Hey everyone,
first of all thanks for reading my question!
I am new to OpenCV and currently I try to get the color at a specific pixel of my image. I looked at various other posts but I am very confused by the results.
https://answers.opencv.org/question/1870/find-pixel-color-out-of-cvmat-on-specific-position/
Lets look at this test code:
cv::Mat greenMat(cv::Size(300, 300), CV_8UC4);
greenMat.setTo(cv::Scalar(0, 255, 0));
for (int i = 0; i < greenMat.cols; i++) {
for (int j = 0; j < greenMat.rows; j++) {
Vec3b color = greenMat.at<Vec3b>(i, j);
std::cout << "color: " << color << std::endl;
}
}
This creates a completely green image. Why is the output of the color not constantly a green one? Instead I get a mix of the following:
color: [255, 0, 0]
color: [0, 255, 0]
color: [0, 0, 255]
color: [0, 0, 0]
What am I misunderstanding here?
Thanks and best wishes,
Philipp