我试图验证分割算法,因此我需要一些好的数据。我想使用纽约大学深度V2数据集(http://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html)。现在我想用点云库png2pcd方法创建一些pcd数据。但我需要一个彩色和深度的图像。彩色的没有问题,但深度以米为单位保存为浮动。所以基本上是这样的值:
[[2.75201321 2.75206947 2.75221062…
有没有可能将这些值保存在png文件中,而不在python中缩放它们?
否。无法在PNG中存储浮点值。可以存储在PNG中的最高分辨率数据是每个样本的16位无符号整数,范围为0..65535。
如果你想存储浮点距离,你需要看看:
- TIFF,可以存储32位和64位浮点,或者
- PFM,可存储32位浮点,或
- 可以存储32位浮点的OpenEXR
如果您询问如何提取1449标记数据集的NYUv2子集,以下转换将起作用。我不确定原始深度值,因为我也有类似的问题,但我的深度值在0-2047之间。你知道用.png格式保存这个文件的方法吗?
for i, (image, depth) in enumerate(zip(f['images'], f['depths'])):
print("SHAPE::", np.shape(image), np.shape(depth), np.max(depth),np.min(depth))
ra_image = image.transpose(2, 1, 0)
ra_depth = depth.transpose(1, 0)
re_depth = (ra_depth/np.max(ra_depth))*255.0
print("AFTER--", np.shape(image), np.shape(depth), np.max(re_depth), np.min(re_depth))
image_pil = Image.fromarray(np.uint8(ra_image))
depth_pil = Image.fromarray(np.uint8(re_depth))
image_name = os.path.join("data", "nyu_datasets", "%05d.jpg" % (i))
# image_pil.save(image_name)
depth_name = os.path.join("data", "nyu_datasets", "%05d.png" % (i))
# depth_pil.save(depth_name)
是。在OpenCV python中:
depthMap = numpy.array([your depth value array])
cv2.imwrite('xxx.png', depthMap)
是的,这是可能的!PNG格式能够为单通道图片保存每像素16位。可以使用整数以米为单位保存深度信息。
depth_image_as_array = np.assaray(depth_image, dtype=float16)
depth_image_as_array = depth_image_as_array * 1000
depth_image = Image.fromarray(depth_image_as_array)
depth_image.save("depth_image.png")