WaterRefraction
Simulate looking through water or wavy glass.
Generates displacement maps from overlaid sine waves at random frequencies, phases, and angles to create a refraction distortion effect.
amplitude_rangeRange for maximum displacement as a fraction of image size. Default: (0.01, 0.05).
wavelength_rangeRange for wave period as a fraction of image size. Default: (0.05, 0.2).
num_waves_rangeRange for number of overlaid sine waves. More waves = more complex distortion. Default: (3, 7).
interpolationOpenCV interpolation flag. Default: cv2.INTER_LINEAR.
mask_interpolationOpenCV interpolation for masks. Default: cv2.INTER_NEAREST.
border_modeOpenCV border mode. Default: cv2.BORDER_REFLECT_101.
fillFill value for constant border. Default: 0.
fill_maskFill value for mask borders. Default: 0.
pProbability of applying the transform. Default: 0.5.
>>> import numpy as np
>>> import albumentations as A
>>> image = np.random.randint(0, 256, (100, 100, 3), dtype=np.uint8)
>>> transform = A.WaterRefraction(amplitude_range=(0.02, 0.04), p=1.0)
>>> result = transform(image=image)["image"]This is a geometric (DualTransform) because the displacement warps the image geometry - masks, bboxes, and keypoints are transformed accordingly.