简体   繁体   中英

Reading Multiple tiff files in python from a folder

I have a folder containing 10K tiff files, how can i import all the files using python so that i can do some predictive modelling.

thanks NK

Use the following approach:

import os 
from PIL import Image
import numpy as np

dirname = 'tiff_folder_path'
final = []
for fname in os.listdir(dirname):
    im = Image.open(os.path.join(dirname, fname))
    imarray = np.array(im)
    final.append(imarray)

final = np.asarray(final) # shape = (60000,28,28)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM