skimage2.util.rescale_legacy#
- skimage2.util.rescale_legacy(image)[source]#
Rescale value range based on dtype (legacy
skimagebehavior).- Parameters:
- imagendarray
Input image.
- Returns:
- rescaled_imagendarray
Rescaled image, of same shape as input
imagebut with a floating dtype (See Notes).
See also
rescale_minmaxRescale
imageto the value range [0, 1].
Notes
Rescales the value range according to the dtype of
imageaccording to the same logic as the legacy functionskimage.util.img_as_float().With a signed integer dtype,
imageis rescaled to the range [-1., 1.].With an unsigned integer dtype,
imageis rescaled to the range [0., 1.].With a floating dtype, the output range will not be modified; the range can be outside the above ranges.
Examples
Signed integers are scaled to range [-1., 1.] >>> rescale_legacy(np.array([-128, 0, 127], dtype=np.int8)) array([-1., 0., 1.])
Unsigned integers are scaled to range [0., 1.] >>> rescale_legacy(np.array([0, 127, 255], dtype=np.uint8)) array([0. , 0.49803922, 1. ])
Range of floating input is preserved >>> rescale_legacy(np.array([0, 127, 255], dtype=float)) array([ 0., 127., 255.])