I have two datasets of .tif files. For data_1
, I can convert the .tif images to arrays by using scipy.imread()
and np.array
. But for the other dataset data_2
, when I apply the same functions, the .tif files are not converted to float arrays.
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)
How do I convert from TIFF to an array?