title: Read 16-bit PNG image file using Python
body: <p>I'm trying to read a PNG image file written in 16-bit data type. The data should be converted to a NumPy array. But I have no idea how to read the file in '16-bit'. I tried with PIL and SciPy, but they converted the 16-bit data to 8-bit when they load it. Could anyone please let me know how to read data from a 16-bit PNG file and convert it to NumPy array without changing the datatype?</p>
  <p>The following is the script that I used.</p>
  <pre><code>from scipy import misc
  import numpy as np
  from PIL import Image
  #make a png file    
  a = np.zeros((1304,960), dtype=np.uint16)
  a[:] = np.arange(960)
  misc.imsave('16bit.png',a)
  
  #read the png file using scipy
  b = misc.imread('16bit.png')
  print &quot;scipy:&quot; ,b.dtype
  
  #read the png file using PIL
  c = Image.open('16bit.png')   
  d = np.array(c)
  print &quot;PIL:&quot;, d.dtype
                 
  </code></pre>