How can I read the pixels value in opencv?
I am trying this code to calculate my binary image pixels value by this code :
int main()
{
Mat img;
img=imread("/home/2b.jpeg", CV_LOAD_IMAGE_UNCHANGED);
namedWindow("win", WINDOW_AUTOSIZE);
imshow("win", img);
for(int i=0; i< img.rows ;i++)
{
for(int j=0; j< img.cols ; j++)
{
cout<<setw(10)<<img.at<int>(i,j);
}
cout<<endl<<endl<<endl;
}
waitKey(0);
return 0;
}
But i get 3 types of value: 0, -1 and some big different numbers like (24342234 , 1324244242, etc)
What is the problem? I drew one black line in paint programs and save the image, or download binary image from internet but i get same results!
I thought when i use binary images i must get 0 for white pixels and 255 for black ones.
how did you type the program? when i typed line by line it comes in a single line in post?