Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV: cvLoadImage opens 16-bit image as 8-bit

Tags:

image

opencv

I am trying to process 16-bit single-channel uncompressed TIFF images with OpenCV 2.1, but when I call cvLoadImage, apparently they get converted to 8-bit:

IplImage* img = cvLoadImage("myImage.tif",
      CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR);

std::cout << img->depth << std::endl;

prints

8

The images have been produced by a fluorescence scanner that generates only this kind of images, and I have confirmed with a commercial software package that they really are 16-bit.

How can I open these images and work with the original bit depth?

like image 926
jpromvi Avatar asked Jul 16 '10 08:07

jpromvi


1 Answers

In OpenCV Loading a tif image (16 bits for example) in python should work by typing:

im = cv.LoadImageM("test.tif",cv.CV_LOAD_IMAGE_UNCHANGED)
like image 196
twerdster Avatar answered Sep 17 '22 22:09

twerdster