DOC: Add example of bad dtype conversion.

This commit is contained in:
Tony S Yu
2012-02-09 10:37:32 -05:00
parent fa821bfb82
commit 06c2ed9d83
+8 -1
View File
@@ -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