0
我有float x,float y,float z值的图像。我想通过复制z值构造一个16位png深度图像。我得到的图像有一些无效点。以下是我的代码。从原始缓冲区数据创建原始图像
uint16_t* depthValues = new uint16_t[size];
auto sampleVector(DepthPoints);
for (unsigned int i = 0; i < sampleVector.size(); i++)
{
depthValues[i] = (sampleVector.at(i).z) * 65536;
}
Mat newDepthImage = cv::Mat(var.height, var.width, CV_16UC1,depthValues);
imwrite(Location, CImage);
可有人告诉我,如果我能浮点值复制到一个unsigned char数组创建图像? 这就是为什么我的图像有无效点?
什么“结果有一些无效点”的确切含义? z值的范围是“[0 - 1]”吗?如果z的值大于1,则大于1的所有值都是65535. – DimChtz
图像的某些区域很暗。我不太确定浮点数据是否可以复制到'uint16_t *'。那是我们如何创建一个深度图像? – MThomas
'z'值的范围是多少?也许所有你需要的是'depthValues [i] = static_cast(sampleVector.at(i).z);'BTW,x,y,z是指R,G,B? –
DimChtz