WaterRefraction

Targets:
image
mask
bboxes
keypoints
volume
mask3d
Image Types:uint8, float32

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.

Arguments
amplitude_range
tuple[float, float]
[0.01,0.05]

Range for maximum displacement as a fraction of image size. Default: (0.01, 0.05).

wavelength_range
tuple[float, float]
[0.05,0.2]

Range for wave period as a fraction of image size. Default: (0.05, 0.2).

num_waves_range
tuple[int, int]
[3,7]

Range for number of overlaid sine waves. More waves = more complex distortion. Default: (3, 7).

interpolation
0 | 1 | 2 | 3 | 4
1

OpenCV interpolation flag. Default: cv2.INTER_LINEAR.

mask_interpolation
0 | 1 | 2 | 3 | 4
0

OpenCV interpolation for masks. Default: cv2.INTER_NEAREST.

border_mode
0 | 1 | 2 | 3 | 4
4

OpenCV border mode. Default: cv2.BORDER_REFLECT_101.

fill
tuple[float, ...] | float
0

Fill value for constant border. Default: 0.

fill_mask
tuple[float, ...] | float
0

Fill value for mask borders. Default: 0.

p
float
0.5

Probability of applying the transform. Default: 0.5.

Examples
>>> 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"]
Notes

This is a geometric (DualTransform) because the displacement warps the image geometry - masks, bboxes, and keypoints are transformed accordingly.