1 | initial version |
Have you tried flag CV_LOAD_IMAGE_ANYDEPTH in imread function? As far as I know it should be present in order to read 16-bit image properly (although I didn't tried it myself so I am not sure that it actually does what it should).
Are you sure that when you accessing values you are not casting the them to unsigned char by mistake?
2 | No.2 Revision |
Have you tried flag CV_LOAD_IMAGE_ANYDEPTH in imread function? As far as I know it should be present in order to read 16-bit image properly (although I didn't tried it myself so I am not sure that it actually does what it should).
Are you sure that when you accessing values you are not casting the them to unsigned char by mistake?
Edit:
Ok, to narrow the search for the problem try following code. I checked that it works properly on my computer:
Mat test1(1000, 1000, CV_16U, Scalar(400));
imwrite("test.tiff", test1);
Mat test2 = imread("stam.tiff", CV_LOAD_IMAGE_ANYDEPTH);
cout << test1.depth() << " " << test2.depth() << endl;
cout << test2.at<unsigned short>(0,0) << endl;