我有两个.tif文件的数据集。对于data_1
,我可以使用scipy.imread()
和np.array
将.tif图像转换为数组。但是对于其他数据集data_2
,当我应用相同的函数时,.tif文件不会转换为float数组。
import h5py
import os
import numpy as np
from scipy import misc
import hickle as hkl
data_1 = np.array([misc.imread(dir1+"/"+file)
for subdir, dirs, files in os.walk(dir1)
for file in files if file[-4:] == '.tif'])
data_2 = np.array([misc.imread(dir2+"/"+file)
for subdir, dirs, files in os.walk(dir2)
for file in files if file[-4:] == '.tif'])
f = h5py.File('images.hkl','w')
f.create_dataset(name='data_1', data = data_1)
f.create_dataset(name='data_2', data = data_2)
如何从TIFF转换为数组?