0

I'm trying to create random shapes and found this beautiful post: https://stackoverflow.com/a/50751932/10267489

It worked fine, and print perfectly using matplotlib. I tried to port it to pillow as follows:

data = np.zeros((size, size, 3), dtype=np.uint8)

x_ = np.round(x).astype(int)
y_ = np.round(y).astype(int)
data[x_,y_] = (250,250,250)
im = Image.fromarray(data)

plt.figure(figsize = (20,20))
plt.imshow(im)
plt.show()

However, it doesn't create the smooth line I get in matplotlib. So the question is if there any way to do that in a better way. A solution I found was to plot it and then use the figure to save it in a buffer and then open in pillow, but was wondering if there is a faster and better approach.

Thank you!!

F_M
  • 301
  • 2
  • 8
  • 1
    Not sure what you are trying to port to Pillow as you still appear to be using `matplotlib`? Nor why you are trying to port to Pillow? Nor what you got as you didn't show your results? Also, why did you remove the `import` statements and setup code you must surely have got if you found you got the wrong results? That just makes everyone have to work harder to help. – Mark Setchell Dec 30 '20 at 19:28
  • 1
    Does this answer your question? [Python save matplotlib figure on an PIL Image object](https://stackoverflow.com/questions/3938676/python-save-matplotlib-figure-on-an-pil-image-object) – pippo1980 Feb 07 '21 at 10:54

0 Answers0