This piece of code is working, but I want to avoid the use of the temporal file, i have tried differents ways but not working. Does anyone knows how to do it? or the temp file is mandatory?
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
...
data = Image.fromarray(np.array(image))
data.save('output/temp.png')
img = plt.imread('output/temp.png')
...
the complete function:
data = pickle.load(datafile)
# IMAGES
image = data['img']
# LABELS
label = data['label']
# SHOW
data = Image.fromarray(np.array(image))
data.save('output/temp.png')
img = plt.imread('output/temp.png')
# Create a figure. Equal aspect so circles look circular
fig, ax = plt.subplots(1)
ax.set_aspect('equal')
# Show the image
ax.imshow(img)
# Now, loop through coord arrays, and create a circle at each x,y pair
for xx, yy in label:
circle = plt.Circle((xx, yy), 10)
ax.add_patch(circle)
# Show the image
plt.show()
Because I want to draw circles in an image loaded with numpy: Drawing circles on image with Matplotlib and NumPy
But I just want to know how to avoid the use of the temporal file. Is it possible?