栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

NYU Depth Dataset V2

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

NYU Depth Dataset V2

NYU Depth Dataset V2数据集的读取

NYUD V2数据集下载网址如下:
https://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html

下载到的Labeled dataset是 .mat文件。

给个百度云链接:
链接:https://pan.baidu.com/s/1zWFKXU37QWEb-ZSYce4rWg
提取码:9u4i

提取好的数据集:

提取好的百度云链接:
链接:https://pan.baidu.com/s/1PtYMsaK6n9Kb_zw00BM_Ww
提取码:km2j

python代码读取数据
import numpy as np
import matplotlib.pyplot as plt
import scipy.io as sio
import h5py
import os
from PIL import Image
import cv2

f = h5py.File(".data\nyu_depth_v2_labeled.mat")

# extract images
images = f["images"]
images = np.array(images)

path_converted = '.\NYU\nyu_images'
if not os.path.isdir(path_converted):
    os.makedirs(path_converted)

images_number = []
for i in range(len(images)):
    images_number.append(images[i])
    a = np.array(images_number[i])
    r = Image.fromarray(a[0]).convert('L')
    g = Image.fromarray(a[1]).convert('L')
    b = Image.fromarray(a[2]).convert('L')
    img = Image.merge("RGB", (r, g, b))
    img = img.transpose(Image.ROTATE_270)
    iconpath = '.\NYU\nyu_images/' + str(i) + '.png'
    img.save(iconpath, optimize=True)
    # exit(0)

print("image extract finished!!!!!")

# extract depths
depths = f["depths"]
depths = np.array(depths)

path_converted = '.\NYU\nyu_depths/'
if not os.path.isdir(path_converted):
    os.makedirs(path_converted)

max = depths.max()
depths = depths / max * 65535
depths = depths.transpose((0, 2, 1))

for i in range(len(depths)):
    print(str(i) + '.png')
    depths_img = np.uint16(depths[i])
    depths_img_new = cv2.flip(depths_img, 1)
    print(depths_img_new.max(), depths_img_new.min())
    iconpath = path_converted + str(i) + '.png'
    cv2.imwrite(iconpath, depths_img_new)
    # exit(0)
print("depths extract finished!!!!!")


labels = f["labels"]
labels = np.array(labels)

path_converted = '.\NYU\nyu_labels/'
if not os.path.isdir(path_converted):
    os.makedirs(path_converted)

labels_max = labels.max()
labels = labels / labels_max * 65535
labels = labels.transpose((0, 2, 1))

for i in range(len(labels)):

    label_img = np.uint16(labels[i])
    label_img_new = cv2.flip(label_img, 1)

    iconpath = '.\NYU\nyu_labels/' + str(i) + '.png'
    cv2.imwrite(iconpath, label_img_new)
    # exit(0)

print("labels extract finished!!!!!")


0.png

提取出来的深度图片和标签图片,我存储成16bit位深。一般的可视化看这些图像都会显得比较黑,以为一般的显示只能显示8bit位深的图片,然后计算机会截取每个pixel的前8bit,这样一来,前8bit的数值一般会偏小所以显得比较黑。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/942877.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号