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
在这里插入图片描述

  • 18
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值