I would like to save a numpy matrix as a .png image, but I cannot do so using the matplotlib since I would like to retain its original size (which apperently the matplotlib doesn't do so since it adds the scale and white background etc). Anyone knows how I can go around this problem using numpy or the PIL please? Thanks
Asked
Active
Viewed 654 times
1
-
see `fig.figimage` http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure.figimage – tacaswell Apr 14 '16 at 15:35
-
http://stackoverflow.com/questions/9910388/matplotlib-plot-small-image-without-resampling/9915223#9915223 – tacaswell Apr 14 '16 at 15:40
-
See also http://stackoverflow.com/questions/902761/saving-a-numpy-array-as-an-image – Warren Weckesser Apr 14 '16 at 16:12
-
Thanks for your help, I've solved it using scipy and posted the answer below :) – SeaGull Apr 14 '16 at 16:29
1 Answers
1
Solved using scipy library
import scipy.misc
...(code)
scipy.misc.imsave(name,array,format)
or
scipy.misc.imsave('name.ext',array) where ext is the extension and hence determines the format at which the image will be stored.

SeaGull
- 41
- 5