[scikit-image] Why does img_as force incoming data

Cedric Espenel cedric.espenel at gmail.com
Wed Jun 21 19:39:15 EDT 2017


Hi Dave,

I think this scikit-image should answers your questions:

http://scikit-image.org/docs/stable/user_guide/data_types.html

Best,

Cedric

On Wed, Jun 21, 2017 at 4:30 PM David Protter <david.protter at 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" <stefanv at 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 at python.org
>
> https://mail.python.org/mailman/listinfo/scikit-image
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scikit-image/attachments/20170621/3144f1bb/attachment.html>


More information about the scikit-image mailing list