2 回答
TA贡献1786条经验 获得超13个赞
您可以使用,matplotlib但显示大量图像往往非常缓慢且效率低下。因此,如果您想更快、更轻松地完成此操作 - 我建议您使用我的名为IPyPlot的包:
import ipyplot
ipyplot.plot_images(images_list, max_images=20, img_width=150)
它支持以下格式的图像:
-string文件路径
-PIL.Image对象
-numpy.ndarray表示图像的对象
它能够在大约 70 毫秒内显示数百张图像
TA贡献1801条经验 获得超16个赞
您可以使用创建多个子图plt.subplots。确定加载图像的列数和行数。就像是:
from os import listdir
import matplotlib.pyplot as plt
path = 'C:/Users/Asus-PC/flowers/'
imagesList = listdir(path)
n_images = len(imagesList)
figure, axes = plt.subplots(n_images, 1) # (columns, rows)
for ax, imgname in zip(axes, imagesList): # Iterate over images and
img = plt.imread(path+imgname) # axes to plot one image on each.
ax.imshow(img) # You can append them to an empty
# list if you need them later.
plt.show()
添加回答
举报
