【发布时间】:2022-01-03 09:45:46
【问题描述】:
我正在读取图像并保存它。但是,保存的图像是空白的。我正在运行以下代码来创建情节
# Create plot
path = i[1][0][0]
img = np.array(Image.open(path))
plt.figure()
fig, ax = plt.subplots(1)
ax.imshow(img)
这将创建上述情节。然后我运行以下命令来保存这个图像。在保存之前,我想查看图像。但是,它会生成一个空白图像。可能是什么问题 ? 我正在使用 Jupyter notebook 并且也运行了命令 %matplotlib inline。
# Save generated image with detections
plt.axis("off")
plt.gca().xaxis.set_major_locator(NullLocator())
plt.gca().yaxis.set_major_locator(NullLocator())
filename = os.path.basename(path).split(".")[0]
output_path = os.path.join("output2", filename+".png")
plt.savefig(output_path, bbox_inches="tight", pad_inches=0.0)
plt.show()
plt.close()
【问题讨论】:
标签: python matplotlib plot jupyter-notebook jupyter-lab