I'm trying to read 16-bit color TIFs using opencv 2.4.3. The problem is that I can't get anything satisfying. All I get is a succession of black and grey lines.
I have tried different way to read the image :
cv::Mat cvimage = cv::imread(imageFile, CV_LOAD_IMAGE_COLOR | CV_LOAD_IMAGE_ANYDEPTH);
cv::Mat cvimage = cv::imread(imageFile, CV_LOAD_IMAGE_UNCHANGED);
cv::imshow("image", cvimage);
type
of cvimage is CV_16UC3
, as expected.
What is the correct way to read 16-bit images using opencv ?
Try:
cv::Mat cvimage = cv::imread(imageFile
, CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH);
If this doesn't work, you can first convert it to PNG
as OpenCV can read and even write 16bit PNG files correctly. You can convert your TIFF
to PNG
without loss.
cv::Mat cvimage = cv::imread(imageFile, -1);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.