I want to use matplotlib to save images. Right now I use fig = plt.figure(figsize=(4,4)), this make images 288 x 288 pixels. How to change the image to 224 x 224 pixels and do not need to resize when fitting VGG model. I use matplotlib.pyplot.imsave to save image
Asked
Active
Viewed 1,689 times
0
-
Have a look [here](https://stackoverflow.com/questions/13714454/specifying-and-saving-a-figure-with-exact-size-in-pixels) – bexi Oct 31 '19 at 09:20
-
`matplotlib` is used to **plot**.. it has nothing to do with resizing images. You can use PIL package instead as done in [here](https://stackoverflow.com/questions/273946/how-do-i-resize-an-image-using-pil-and-maintain-its-aspect-ratio). – Anwarvic Oct 31 '19 at 09:20
1 Answers
0
I am guessing you are using fig.savefig to save. You set a figure size of 4 inch by 4 inch, so to get 224x224 pixels you need to set a dpi of 224/4 = 56:
fig.savefig("$path", dpi=56)

BlaXXuN
- 121
- 3