def load_images(directory):
images = []
for root, dirnames, filenames in os.walk(directory):
for filename in filenames:
if re.search("\.(jpg|jpeg|png|bmp|tiff)$", filename):
filepath = os.path.join(root, filename)
image = ndimage.imread(filepath, mode="L")
images.append(image)
images = np.array(images)
array_shape = np.append(images.shape[0:3], 1)
images = np.reshape(images, (array_shape))
return images
评论列表
文章目录