Asymmetric behavior in dtype conversion
Christoph Gohlke
cjgohlke at gmail.com
Wed Dec 21 12:15:50 EST 2011
On 12/21/2011 8:41 AM, St�fan van der Walt wrote:
> On Wed, Dec 21, 2011 at 1:30 AM, Tony Yu<tsyu80 at gmail.com> wrote:
>> I think one of two things should happen:
>>
>> 1)
>> [uint -> int]: expand uint to *full* range of int.
>> [int -> uint]: unchanged (squeeze into range of uint)
>>
>> 2)
>> [uint -> int]: unchanged (fill *positive* range of int)
>> [int -> uint]: clip negative values from int
> People very often represent images in signed integers, even though
> they only manipulate positive values, e.g. storing 0-255 in int8. So
> the conversion to signed should not spread those values over the
> entire range. However, I think you're right that we should add the
> clipping in 2 to avoid the conversion bias, along with a nice big
> warning.
>
> Regards
> St�fan
>
At this point it might be worth considering other cases that are
currently not well handled by skimage dtype conversions. For example:
1) float images in the range 0.0 - 255.0
2) 1 bit images stored as (u)int
3) 10 and 12 bit images stored as uint16
Christoph
More information about the scikit-image
mailing list