diff --git a/skimage/_shared/testing.py b/skimage/_shared/testing.py index 0d40c47f..db3bcfe8 100644 --- a/skimage/_shared/testing.py +++ b/skimage/_shared/testing.py @@ -119,8 +119,13 @@ def ubyte_check(plugin, fmt='png'): testing.assert_allclose(r3, img) img4 = img_as_int(img) - r4 = roundtrip(img4, plugin, fmt) - testing.assert_allclose(r4, img) + if fmt.lower() in (('tif', 'tiff')): + img4 -= 100 + r4 = roundtrip(img4, plugin, fmt) + testing.assert_allclose(r4, img4) + else: + r4 = roundtrip(img4, plugin, fmt) + testing.assert_allclose(r4, img_as_ubyte(img4)) img5 = img_as_uint(img) r5 = roundtrip(img5, plugin, fmt) @@ -150,8 +155,13 @@ def full_range_check(plugin, fmt='png'): testing.assert_allclose(r3, img_as_uint(img)) img4 = img_as_int(img) - r4 = roundtrip(img4, plugin, fmt) - testing.assert_allclose(r4, img4) + if fmt.lower() in (('tif', 'tiff')): + img4 -= 100 + r4 = roundtrip(img4, plugin, fmt) + testing.assert_allclose(r4, img4) + else: + r4 = roundtrip(img4, plugin, fmt) + testing.assert_allclose(r4, img_as_uint(img4)) img5 = img_as_uint(img) r5 = roundtrip(img5, plugin, fmt) diff --git a/skimage/io/_plugins/pil_plugin.py b/skimage/io/_plugins/pil_plugin.py index decf0281..a692da54 100644 --- a/skimage/io/_plugins/pil_plugin.py +++ b/skimage/io/_plugins/pil_plugin.py @@ -75,6 +75,8 @@ def pil_to_ndarray(im, dtype=None): elif im.mode.startswith('I;16'): shape = im.size dtype = '>u2' if im.mode.endswith('B') else ' img_as_uint8 - - Other unsigned integers and floating point -> img_as_uint16 - - Other signed integers -> img_as_int16 + - Floating point and other integers -> img_as_uint16 References ----------