我下载的是带标签的NYUV2数据集,下载写来的格式是.mat
原图,深度图,labels的提取方式参考此博客
提取各类名称保存为txt
# -*- coding: utf-8 -*-
import h5py
f=h5py.File("./nyu_depth_v2_labeled.mat")
ft = open('names.txt', 'w+')
#print(f["names"].shape) #打印查看类别个数,共894类
for j in range (894):
name = f["names"][0][j]
obj = f[name]
strr = "".join(chr(i) for i in obj[:])
ft.write(strr + '\n')
ft.close()
结果图
提取原图images(RGB图)
import numpy as np
import matplotlib.pyplot as plt
import scipy.io as sio
import h5py
import os
f=h5py.File("./nyu_depth_v2_labeled.mat")
images=f["images"]
images=np.array