Convert byte intensities to floating values using a chosen maximum, while preserving the values and precision of floating inputs.
max_valueThe maximum possible input value. If None, the transform will try to infer the maximum value by inspecting the data type of the input image:
pProbability of applying the transform. Default: 1.0.
>>> import numpy as np
>>> import albumentations as A
>>>
# Convert uint8 image to float
>>> image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
>>> transform = A.ToFloat(max_value=None)
>>> float_image = transform(image=image)['image']
>>> assert float_image.dtype == np.float32
>>> assert 0 <= float_image.min() <= float_image.max() <= 1.0
>>>Converted image in the input container.
FromFloat: The inverse operation, converting from float back to the original data type.