From 9bccefbc5e083e09f2d4ff6529e244981366519f Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Fri, 21 Nov 2014 22:36:04 +0100 Subject: [PATCH 1/2] Update docs for img_as_ubyte The line in `img_as_ubyte` needs correction; ubyte cannot hold negative data. From a quick experiment it seems like both `img_as_uint` and `img_as_ubyte` clip negative values (and not shift them to the positive domain). --- skimage/util/dtype.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/skimage/util/dtype.py b/skimage/util/dtype.py index 3f85cc2b..e88545fc 100644 --- a/skimage/util/dtype.py +++ b/skimage/util/dtype.py @@ -304,7 +304,7 @@ def img_as_uint(image, force_copy=False): Notes ----- - Negative input values will be shifted to the positive domain. + Negative input values will be clipped. """ return convert(image, np.uint16, force_copy) @@ -351,8 +351,7 @@ def img_as_ubyte(image, force_copy=False): Notes ----- - If the input data-type is positive-only (e.g., uint16), then - the output image will still only have positive values. + Negative input values will be clipped. """ return convert(image, np.uint8, force_copy) From 0e7daf41dcbd0fec16929a76272242ddd09f1004 Mon Sep 17 00:00:00 2001 From: Almar Klein Date: Tue, 25 Nov 2014 08:43:58 +0100 Subject: [PATCH 2/2] Update docs in dtype.py: mention scaling of values --- skimage/util/dtype.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/skimage/util/dtype.py b/skimage/util/dtype.py index e88545fc..1a392537 100644 --- a/skimage/util/dtype.py +++ b/skimage/util/dtype.py @@ -304,7 +304,8 @@ def img_as_uint(image, force_copy=False): Notes ----- - Negative input values will be clipped. + Negative input values will be clipped. + Positive values are scaled between 0 and 65535. """ return convert(image, np.uint16, force_copy) @@ -327,6 +328,7 @@ def img_as_int(image, force_copy=False): Notes ----- + The values are scaled between -32768 and 32767. If the input data-type is positive-only (e.g., uint8), then the output image will still only have positive values. @@ -351,7 +353,8 @@ def img_as_ubyte(image, force_copy=False): Notes ----- - Negative input values will be clipped. + Negative input values will be clipped. + Positive values are scaled between 0 and 255. """ return convert(image, np.uint8, force_copy)