title: Save numpy array as image with high precision (16 bits) with scikit-image
body: <p>I am working with 2D floating-point numpy arrays that I would like to save to greyscale .png files with high precision (e.g. 16 bits). I would like to do this using the scikit-image <code>skimage.io</code> package if possible.</p>
  
  <p>Here's the main thing I've tried:</p>
  
  <pre><code>import numpy as np
  from skimage import io, exposure, img_as_uint, img_as_float
  
  im = np.array([[1., 2.], [3., 4.]], dtype='float64')
  im = exposure.rescale_intensity(im, out_range='float')
  im = img_as_uint(im)
  im
  </code></pre>
  
  <p>produces:</p>
  
  <pre><code>array([[    0, 21845],
         [43690, 65535]], dtype=uint16)
  </code></pre>
  
  <p>First I tried saving this as an image then reloading using the Python Imaging Library:</p>
  
  <pre><code># try with pil:
  io.use_plugin('pil')
  io.imsave('test_16bit.png', im)
  im2 = io.imread('test_16bit.png')
  im2
  </code></pre>
  
  <p>produces:</p>
  
  <pre><code>array([[  0,  85],
         [170, 255]], dtype=uint8)
  </code></pre>
  
  <p>So somewhere (in either the write or read) I have lost precision. I then tried with the matplotlib plugin:</p>
  
  <pre><code># try with matplotlib:
  io.use_plugin('matplotlib')
  io.imsave('test_16bit.png', im)
  im3 = io.imread('test_16bit.png')
  im3
  </code></pre>
  
  <p>gives me a 32-bit float:</p>
  
  <pre><code>array([[ 0.        ,  0.33333334],
         [ 0.66666669,  1.        ]], dtype=float32)
  </code></pre>
  
  <p>but I doubt this is really 32-bits given that I saved a 16-bit uint to the file. It would be great if someone could point me to where I'm going wrong. I would like this to extend to 3D arrays too (i.e. saving 16 bits per colour channel, for 48 bits per image).</p>
  
  <h2>UPDATE:</h2>
  
  <p>The problem is with imsave. The images are 8 bits per channel. How can one use io.imsave to output a high bit-depth image? </p>