Hi David,

Yes, img_float.astype('uint16') will work, but you'll need to make sure you map 
your float image to the range 0-65535.

Juan.

On 22 Jun 2017, 9:29 AM +1000, David Protter <david.prot...@gmail.com>, wrote:
> Thank you! Will this also work going back the other way? (Float to uint?)
>
> > On Jun 21, 2017 5:16 PM, "Stefan van der Walt" <stef...@berkeley.edu> wrote:
> > > Hi Dave
> > >
> > > On Wed, Jun 21, 2017, at 15:22, David Protter wrote:
> > > > Hi all, new here and having a lot of fun using Skimage for scientific 
> > > > image analysis.
> > >
> > > Glad to hear it!
> > >
> > > > I’m doign some normalization on images coming in as uint16, to expand 
> > > > their dynamic range. After normalization, images are float64, and I’m 
> > > > trying to convert them back to uint16. However, it seems like all the 
> > > > img_as functions ignore the kind of float coming in, since anything of 
> > > > kind float is constrained to [-1 to 1]. Below is the section out of the 
> > > > convert() function that seems to do this.
> > >
> > > Floating point images are expected to be between -1 and 1, as described 
> > > here:
> > >
> > > http://scikit-image.org/docs/stable/user_guide/data_types.html
> > >
> > > However, many functions support working on data in its original range, by 
> > > specifying `preserve_range=True`.
> > >
> > > To convert your data from uint16 to float without changing its range, do:
> > >
> > > img_float = img.astype(float)
> > >
> > > Best regards
> > > Stéfan
> > >
> _______________________________________________
> scikit-image mailing list
> scikit-image@python.org
> https://mail.python.org/mailman/listinfo/scikit-image
_______________________________________________
scikit-image mailing list
scikit-image@python.org
https://mail.python.org/mailman/listinfo/scikit-image

Reply via email to