Saving A Numpy Array As An Image (instructions)
I found my answer in a previous post: Saving a Numpy array as an image. The only problem being, there isn't much instruction on using the PyPNG module. There are only a few exampl
Solution 1:
You might be better off using PIL:
from PIL import Image
import numpy as np
data = np.random.random((100,100))
#Rescale to 0-255 and convert to uint8
rescaled = (255.0 / data.max() * (data - data.min())).astype(np.uint8)
im = Image.fromarray(rescaled)
im.save('test.png')
Solution 2:
import matplotlib.pyplotas plt
import numpy as np
plt.imshow(np.random.random(100, 100))
plt.savefig('')
Solution 3:
It would be best to use scipy for it.
from scipy.misc import imsave
# x is the array you want to save
imsave("image.png", x)
Full documentation is here: https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.misc.imsave.html
Post a Comment for "Saving A Numpy Array As An Image (instructions)"