I started working with OPENCV and I firstly test some basic commands. At the moment I try to print out a particular value of a jpg image. I already read several posts and constructed the following C++ program.
#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main() //(int argc, char** argv)
{
Mat image;
image = imread("Desert.jpg", IMREAD_COLOR);
cout << image.at<Vec3b>(1, 1)[0] << std::endl;
cout << image.at<Vec3b>(1,1) << std::endl;
image.at<Vec3b>(1, 1)[0] = 10;
cout << image.at<Vec3b>(1, 1) << std::endl;
return 0;
}
The output in the terminal is
▒
[205, 123, 51]
[10, 123, 51]
So I get a strange value when printing out the first channel of pixel (1,1). Contrary to that I can print all three at once. I can even change the value of pixel (1,1) in channel 1 using the same syntax.
I use visual Studio and Vesion 3.4.1 of OPENCV. Any suggestions or comments why this happens?