mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-26 13:37:17 +08:00
DOC: Add example of bad dtype conversion.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user