I am reading an image and saving it. However, the saved image is a blank. I am running the following code to create the plot
# Create plot
path = i[1][0][0]
img = np.array(Image.open(path))
plt.figure()
fig, ax = plt.subplots(1)
ax.imshow(img)
This creates the above plot. Then I run the following commands to save this image. Before saving I want to see the image. However , it generates a blank image. What could be the issue ? I am using Jupyter notebook and have run the command %matplotlib inline as well.
# 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()
CodePudding user response: