Convert the input image to float32 in [0, 1] by dividing by max_value. Useful for normalizing before neural networks or algorithms that expect float input.
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
>>>Image in floating point representation, with values in range [0, 1.0].
FromFloat: The inverse operation, converting from float back to the original data type.