Is there any way to save a numpy array as a 16 bit image (tif, png) using any of the commonly available python packages? This is the only way that I could get to work in the
As mentioned, PyPNG is very useful. For Enthought users it can be installed as e.g.:
conda install -c eaton-lab pypng
I'd use the from_array method of the shelf:
import png
import numpy as np
bit_depth = 16
my_array = np.ones((800, 800, 3))
png.from_array(my_array*2**bit_depth-1, 'RGB;%s'%bit_depth).save('foo.png')
Mode uses PIL style format, e.g. 'L', 'LA', 'RGB' or 'RGBA', followed by ';16' or ';8' too set bit depth. If bit depth is omitted, the dtype of the array is used.
Read more here.