Obtaining Pixelvalue with various formats
I tried to get the value underneath an cv::Mat dImg
in the format 16UC1
but only get rubbish when obtaining one pixel value.
I expect an int ranging inbetween 0 and 2^16-1 (65535) but this is what i get:
135530515
583506521733990419
4.45466e-34
1.18455e-269
with
cout<<dImg.at<int>(240,320)<<endl;
cout<<dImg.at<long>(240,320)<<endl;
cout<<dImg.at<float>(240,320)<<endl;
cout<<dImg.at<double>(240,320)<<endl;
EDIT: The image resolution is 640x480. I choose the position randomly, for others i get the same. (c++). EDIT2: Using ansers solution i get:
125
11
157
8
0
0
This looks fine yay :)