如果您询问提取 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)