numpy.array to PNG file and back numpy.array to PNG file and back numpy numpy

numpy.array to PNG file and back


scikit-image makes this pretty easy:

from skimage.io import imread, imsaveimport numpy as npx = np.ones((100, 100), dtype=np.uint16)imsave('test.png', x)y = imread('test.png')(x == y).all()  # True