Can I save a numpy array as a 16-bit image using “normal” (Enthought) python?

后端 未结 5 1729
抹茶落季
抹茶落季 2020-12-03 12:15

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

5条回答
  •  臣服心动
    2020-12-03 12:54

    This explanation of png and numpngw is very helpful! But, there is one small "mistake" I thought I should mention. In the conversion to 16 bit unsigned integers, the y.max() should have been y.min(). For the picture of random colors, it didn't really matter but for a real picture, we need to do it right. Here's the corrected line of code...

    z = (65535*((y - y.min())/y.ptp())).astype(np.uint16)
    

提交回复
热议问题