machinevisiontoolbox.Image.stretch
- Image.stretch(max=1, range=None, clip=True)
Image normalisation
- Parameters:
max (int, float, optional) – maximum value of output pixels, defaults to 1
range (array_like(2), optional) – range[0] is mapped to 0, range[1] is mapped to max
clip (bool, optional) – clip pixel values to interval [0, max], defaults to True
- Returns:
Image with pixel values stretched to M across r
- Return type:
Image
Returns a normalised image in which all pixel values are linearly mapped to the interval of 0.0 to
max
. That is, the minimum pixel value is mapped to 0 and the maximum pixel value is mapped tomax
.If
range
is specified thenrange[0]
is mapped to 0.0 andrange[1]
is mapped tomax
. Ifclip
is False then pixels less thanrange[0]
will be mapped to a negative value and pixels greater thanrange[1]
will be mapped to a value greater thanmax
.Example:
>>> from machinevisiontoolbox import Image >>> img = Image([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) >>> img.stretch().A array([[0. , 0.125, 0.25 ], [0.375, 0.5 , 0.625], [0.75 , 0.875, 1. ]])
- References:
Robotics, Vision & Control for Python, Section 12.1, P. Corke, Springer 2023.