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