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()
添加回答
舉報