2016-04-21 27 views

回答

0

您可以使用PIL(Python Imaging Library)http://www.pythonware.com/products/pil/來加載圖像。 然後,您可以製作一個腳本來讀取目錄中的圖像並將它們加載到python中,如下所示。

#!/usr/bin/python 
from os import listdir 
from PIL import Image as PImage 

def loadImages(path): 
    # return array of images 

    imagesList = listdir(path) 
    loadedImages = [] 
    for image in imagesList: 
     img = PImage.open(path + image) 
     loadedImages.append(img) 

    return loadedImages 

path = "/path/to/your/images/" 

# your images in an array 
imgs = loadImages(path) 

for img in imgs: 
    # you can show every image 
    img.show() 
+0

非常感謝,那樣做:) – Aditya

0

您可以使用glob和imageio python包實現相同。下面是python 3中的代碼:

import glob 
import imageio 

for image_path in glob.glob("<your image directory path>\\*.png"): 
    im = imageio.imread(image_path) 
    print (im.shape) 
    print (im.dtype)