我有一个 numpy 矩阵,其中每一行都是一张图片。我可以重塑行并使用 matplotlib.pyplot 显示图像。问题是:我不想单独显示图像,我想像视频一样依次显示它们。
这在Python中怎么可能呢?
好吧,我不知道这是否是最好的方法,但我已经使用 matplotlib.pyplot 来解决我的问题。将其导入为“plt”并执行以下操作:
matrix=numpy.genfromtxt(path,delimiter=',') # Read the numpy matrix with images in the rows
c=matrix[0]
c=c.reshape(120, 165) # this is the size of my pictures
im=plt.imshow(c)
for row in matrix:
row=row.reshape(120, 165) # this is the size of my pictures
im.set_data(row)
plt.pause(0.02)
plt.show()
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)