3

I tried to follow an example given here. The code segment is

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)
io.imsave('test_16bit.png', im)
im2 = io.imread('test_16bit.png')

However, compiling this program gives the following warning message. What might cause the problem, and how to fix it?

/devl/lib/python3.4/site-packages/scikit_image-0.12.3-py3.4-linux-x86_64.egg/skimage/util/dtype.py:110: UserWarni: Possible precision loss when converting from float64 to uint16 "%s to %s" % (dtypeobj_in, dtypeobj))

Community
  • 1
  • 1
user297850
  • 7,705
  • 17
  • 54
  • 76
  • Well ```img_as_uint``` converts from float-based storage to uint-based storage. Of course that's suboptimal! If the input-pixels are integers, you should never start with float64. Not sure, what rescale_intensity will do though (if it can take ints and output ints). And one more thing: *python code is not compiled*. This is a runtime-error. – sascha Sep 18 '16 at 14:53
  • So, basically, remove the call to `img_as_uint` and you should be fine. You can safely ignore the warning, or you can suppress it using `warnings.catch_warnings`. – Stefan van der Walt Sep 18 '16 at 15:50

0 Answers0