bundles / skimage 0.26.1rc0.dev0+git20260530.b607368ff / skimage / exposure / exposure / rescale_intensity
function
skimage.exposure.exposure:rescale_intensity
source: /dev/scikit-image/src/skimage/exposure/exposure.py :491
Signature
def rescale_intensity ( image , in_range = image , out_range = dtype ) Summary
Return image after stretching or shrinking its intensity levels.
Extended Summary
The desired intensity range of the input and output, in_range and out_range respectively, are used to stretch or shrink the intensity range of the input image. See examples below.
Parameters
image: arrayImage array.
in_range, out_range: str or 2-tuple, optionalMin and max intensity values of input and output image. The possible values for this parameter are enumerated below.
'image'
Use image min/max as the intensity range.
'dtype'
Use min/max of the image's dtype as the intensity range.
dtype-name
Use intensity range based on desired dtype. Must be valid key in
DTYPE_RANGE.2-tuple
Use
range_valuesas explicit min/max intensities.
Returns
out: arrayImage array after rescaling its intensity. This image is the same dtype as the input image.
Notes
Examples
By default, the min/max intensities of the input image are stretched to the limits allowed by the image's dtype, since `in_range` defaults to 'image' and `out_range` defaults to 'dtype':image = np.array([51, 102, 153], dtype=np.uint8) rescale_intensity(image)✓
1.0 * image
✓image_float = 1.0 * image rescale_intensity(image_float)✓
rescale_intensity(image_float, in_range=(0, 255))
✓rescale_intensity(image_float, in_range=(0, 102))
✓image = np.array([-10, 0, 10], dtype=np.int8) rescale_intensity(image, out_range=(0, 127))✓
rescale_intensity(image, out_range=(0, 127)).astype(np.int8)
✓image = np.array([130, 130, 130], dtype=np.int32) rescale_intensity(image, out_range=(0, 127)).astype(np.int32)✓
See also
Aliases
-
skimage.exposure.rescale_intensity