如何使用 matlib 函数 plt.imshow(image) 显示多张图片?
例如我的代码如下:
for file in images:
process(file)
def process(filename):
image = mpimg.imread(filename)
<something gets done here>
plt.imshow(image)
我的结果显示只有最后处理过的图像有效地覆盖了其他图像
最佳答案
您可以使用以下设置框架来显示多个图像:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
def process(filename: str=None) -> None:
"""
View multiple images stored in files, stacking vertically
Arguments:
filename: str - path to filename containing image
"""
image = mpimg.imread(filename)
# <something gets done here>
plt.figure()
plt.imshow(image)
for file in images:
process(file)
这将垂直堆叠图像
关于python - 使用 plt.imshow() 显示多张图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41210823/