From b8a19a0c73cd5680fac2c866e38108bc9994a589 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Thu, 9 Feb 2012 10:27:29 -0500 Subject: [PATCH 1/3] DOC: Add (u)int32 data type ranges to table. --- doc/source/user_guide/data_types.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/source/user_guide/data_types.txt b/doc/source/user_guide/data_types.txt index 7ce032f1..5ecada3c 100644 --- a/doc/source/user_guide/data_types.txt +++ b/doc/source/user_guide/data_types.txt @@ -8,18 +8,22 @@ data types [1]_, *i.e.* "dtypes". To avoid distorting image intensities (see `Rescaling intensity values`_), we assume that images use the following dtype ranges: -========= =============== +========= =============================== Data type Range -========= =============== +========= =============================== uint8 0 to 255 uint16 0 to 65535 +uint32 0 to 2\ :sup:`32` float 0 to 1 int8 -128 to 127 int16 -32768 to 32767 -========= =============== +int32 -2\ :sup:`31` to 2\ :sup:`31`-1 +========= =============================== Note that float images are restricted to the range 0 to 1 even though the data -type itself can exceed this range. +type itself can exceed this range; all integer dtypes, on the other hand, have +pixel intensities that can span the entire data type range. Currently, *64-bit +(u)int images are not supported*. Functions in ``skimage`` are designed so that they accept any of these dtypes, but, for efficiency, *may return an image of a different dtype* (see `Output From fa821bfb82a195284fc9a86b972e0d0cec39e2af Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Thu, 9 Feb 2012 10:32:40 -0500 Subject: [PATCH 2/3] DOC: Tweak superscript formatting. Note: vertical-alignment is off when line-height for superscripts is not 0. --- doc/source/themes/agogo/static/agogo.css_t | 5 +++++ doc/source/user_guide/data_types.txt | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/source/themes/agogo/static/agogo.css_t b/doc/source/themes/agogo/static/agogo.css_t index fc6ae242..20219626 100644 --- a/doc/source/themes/agogo/static/agogo.css_t +++ b/doc/source/themes/agogo/static/agogo.css_t @@ -599,6 +599,11 @@ pre { border-right: none; } +sup { + font-size: x-small; + line-height: 0; +} + tt { background-color: #ecf0f3; padding: 0 1px 0 1px; diff --git a/doc/source/user_guide/data_types.txt b/doc/source/user_guide/data_types.txt index 5ecada3c..da7f2ed4 100644 --- a/doc/source/user_guide/data_types.txt +++ b/doc/source/user_guide/data_types.txt @@ -8,17 +8,17 @@ data types [1]_, *i.e.* "dtypes". To avoid distorting image intensities (see `Rescaling intensity values`_), we assume that images use the following dtype ranges: -========= =============================== +========= ================================= Data type Range -========= =============================== +========= ================================= uint8 0 to 255 uint16 0 to 65535 uint32 0 to 2\ :sup:`32` float 0 to 1 int8 -128 to 127 int16 -32768 to 32767 -int32 -2\ :sup:`31` to 2\ :sup:`31`-1 -========= =============================== +int32 -2\ :sup:`31` to 2\ :sup:`31` - 1 +========= ================================= Note that float images are restricted to the range 0 to 1 even though the data type itself can exceed this range; all integer dtypes, on the other hand, have From 06c2ed9d83657d4a2d6224a5f79ed7d395909513 Mon Sep 17 00:00:00 2001 From: Tony S Yu Date: Thu, 9 Feb 2012 10:37:32 -0500 Subject: [PATCH 3/3] DOC: Add example of bad dtype conversion. --- doc/source/user_guide/data_types.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/doc/source/user_guide/data_types.txt b/doc/source/user_guide/data_types.txt index da7f2ed4..1db55543 100644 --- a/doc/source/user_guide/data_types.txt +++ b/doc/source/user_guide/data_types.txt @@ -30,7 +30,14 @@ but, for efficiency, *may return an image of a different dtype* (see `Output types`_). If you need a particular dtype, ``skimage`` provides utility functions that convert dtypes and properly rescale image intensities (see `Input types`_). You should **never use** ``astype`` on an image, because it -violates these assumptions about the dtype range. +violates these assumptions about the dtype range:: + + >>> from skimage import img_as_float + >>> image = np.arange(0, 50, 10, dtype=np.uint8) + >>> print image.astype(np.float) # These float values are out of range. + [ 0. 10. 20. 30. 40.] + >>> print img_as_float(image) + [ 0. 0.03921569 0.07843137 0.11764706 0.15686275] Input types