我有一个 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()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3732 次 |
| 最近记录: |