0

I have a 2D numpy array stores values from 0 to 1000, for example

a = [[21 545 953]
     [43 632 423]]

I want to save this array to an image (.png) without scaling all the values to 0 - 255. I tried sp.misc.toimage but it seems it always scale the data. Any idea how to do this?

trminh89
  • 877
  • 2
  • 10
  • 17
  • What colour format is this suppose to be ? It is scaled to 0-255 so you can see it as a grey-scale image. – Mel Dec 08 '15 at 13:02
  • Maybe you want to save as 16 bit image ? http://stackoverflow.com/questions/24240039/save-numpy-array-as-image-with-high-precision-16-bits-with-scikit-image, http://stackoverflow.com/questions/13901197/retain-unchanged-data-when-saving-numpy-array-to-image-with-scipy-imsave – Mel Dec 08 '15 at 13:07
  • I just want to save an image with exactly values from the array, the colour format can be back/white – trminh89 Dec 08 '15 at 13:21
  • Thanks @tmoreau, your link works! – trminh89 Dec 08 '15 at 13:29
  • You could also use `numpngw` (https://pypi.python.org/pypi/numpngw/): `numpngw.write_png('image.png', a.astype(np.uint16))` – Warren Weckesser Dec 08 '15 at 17:01

0 Answers0