I am working with OpenCV using C++. I would like to create an image with 3 colors: red, white and black. In detail, I want the background red and then a part white and a part black based on some conditions.
The problem that I have is that when I set a color to white it becomes BLUE.
Could someone know why this happen and how to solve it?
This is my code:
//initial image total red
cv::Mat image(Size(w, h), CV_8UC3, cv::Scalar(0, 0, 255));
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int pixel_v = (int)imggray.at<uchar>(i,j);
if (pixel_v < 200) {
int pixel_bl = (int)imgBool.at<uchar>(i, j);
if (pixel_bl > 200) {
//HERE A WANT WHITE PIXELS, but they are blue
image.at<Vec3b>(i, j) = (255, 255, 255);
}
else {
//black: this works
image.at<Vec3b>(i, j) = (0, 0, 0);
}
}
}
}