I have a 2d numpy.array object of a dtype=uint16 object representing a grayscale image. How to save it in a PNG file, and then read it back, get the same array?
numpy.array
dtype=uint16
scikit-image makes this pretty easy:
from skimage.io import imread, imsave import numpy as np x = np.ones((100, 100), dtype=np.uint16) imsave('test.png', x) y = imread('test.png') (x == y).all() # True
Source: https://habr.com/ru/post/1201232/More articles:fatal error in magento admin part add category - magentoEfficient hash function for low entropy alphanumeric strings - alphanumericsimilar to Android INSTALL_REFERRER in Iphone - iosNuGet internal server unavailable - powershellGetting country name from country code in WooCommerce - phpAre there any memory gaps in this code? - c ++Why is covariance and contravariance named so? - c #Explicit specialization of function templates causes linker error - c ++CKEditor custom properties do not work and do not occur - javascriptError processing route error in ember.js with ember-data - ember.jsAll Articles