I am using Ubuntu 12.04 and OpenCV 2
I have written the following code :
IplImage* img =0;
img = cvLoadImage(\"nature.jpg\");
if(img != 0)
{
Mat
You have to specify the correct type for cv::Mat::at(i,j). You are accessing the pixel as int, while it should be a vector of uchar. Your code should look something like this:
IplImage* img = 0;
img = cvLoadImage("nature.jpg");
if(img != 0)
{
Mat Img_mat(img);
std::vector BGR;
split(Img_mat, BGR);
Vec3b data = BGR[0].at(i,j);
// data[0] -> blue
// data[1] -> green
// data[2] -> red
}