twocan.stretch_255
- twocan.stretch_255(image: ndarray) ndarray[source]
Convert an image to 8-bit grayscale by stretching its range to [0, 255].
This function linearly stretches the intensity values of an image to span the full 8-bit range [0, 255]. If the input image has zero maximum value, the original image is returned unchanged.
- Parameters:
image (np.ndarray) – Input image array of any shape and dtype.
- Returns:
8-bit grayscale image with values in [0, 255] and dtype uint8. Returns original image unchanged if max value is 0.
- Return type:
np.ndarray