**VS2015forOpeCV411版本读取图像深度单通道16bit**

VS2015forOpeCV411版本读取图像深度单通道16bit

#include
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main()
{
Mat src;
src = imread(“D:/1.tif”, IMREAD_ANYDEPTH);
if (src.empty())
{
cout << “pic error” << endl;
return -1;
}
ushort *pdata = src.ptr(0);
cout << “pix–” << src.elemSize() << endl;

for (int i = 0; i < 640; i++)
{
	printf("%ld ", *pdata++);
}
namedWindow("tt");
imshow("tt", src);
waitKey(0);
return 0;

}

imread(读取图片函数)函数第二参数诠释:
注:读取图片的时候第一个参数字符串中要使用“D:/1.tif“,斜杠打反了会转义后面的字符。
flag=-1时,8位深度,原通道
flag=0,8位深度,1通道
flag=1, 8位深度 ,3通道
flag=2,原深度,1通道
flag=3, 原深度,3通道
flag=4,8位深度 ,3通道

   IMREAD_UNCHANGED            = -1, //!< If set, return the loaded image as is (with alpha channel, otherwise it gets cropped).
   IMREAD_GRAYSCALE            = 0,  //!< If set, always convert image to the single channel grayscale image (codec internal conversion).
   IMREAD_COLOR                = 1,  //!< If set, always convert image to the 3 channel BGR color image.
   IMREAD_ANYDEPTH             = 2,  //!< If set, return 16-bit/32-bit image when the input has the corresponding depth, otherwise convert it to 8-bit.
   IMREAD_ANYCOLOR             = 4,  //!< If set, the image is read in any possible color format.

读取图片的灰度值(这里以单通道16bit为例)
ushort *pdata = src.ptr(0);
ptr读取的是一行的数据。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值