Image.stretch#
- Image.stretch(max: int | float = 1, range: Any = None, clip: bool = True) Self[source]#
Image normalisation
- Parameters:
- Returns:
Image with pixel values stretched to M across r
- Return type:
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
rangeis specified thenrange[0]is mapped to 0.0 andrange[1]is mapped tomax. Ifclipis 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.Examples
>>> 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. ]], dtype=float32)
References