#include<iostream>
#include<opencv2/highgui.hpp>
#include<opencv2/core/core.hpp>
using namespace cv;
using namespace std;
int main(int argc,char**argv)
{
cv::Mat color,depth;
color=imread("/home/finer/Desktop/images/1.png",IMREAD_COLOR);
depth=imread("/home/finer/Desktop/images/1_depth.png",-1);
imshow("color image",color);
imshow("depth image",depth);
Mat depth1;
depth.convertTo(depth1,CV_16U,1.0/500);
waitKey(0);
for(int i = 0; i<10;++i)
{
unsigned short*d = depth1.ptr<unsigned short>(i+100);
cout<<d[188]<<endl;
}
}
上面是指针访问图像像素点的方法,相应的还有指针读取以及迭代器读取。
convertTo 用于将对象图像像素格式转换为指定像素格式。 第三个参数为缩放因子,即每对象图像像素每个值除以500,注意为double类型。