[英]Read 16-bit tif with opencv
I'm trying to read 16-bit color TIFs using opencv 2.4.3. 我正在尝试使用opencv 2.4.3读取16位彩色TIF。 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. 正如预期的那样,cvimage的
type
是CV_16UC3
。
What is the correct way to read 16-bit images using opencv ? 使用opencv读取16位图像的正确方法是什么?
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. 如果这不起作用,您可以先将其转换为
PNG
因为OpenCV可以读取甚至正确写入16位PNG文件。 You can convert your TIFF
to PNG
without loss. 您可以将您的
TIFF
转换为PNG
而不会丢失。
cv::Mat cvimage = cv::imread(imageFile, -1);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.