File size: 458 Bytes
4b9cecd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import numpy as np
import cv2
from PIL import Image
def apply_wave_effect(pil_img):
img = np.array(pil_img)
rows, cols = img.shape[:2]
map_y, map_x = np.indices((rows, cols), dtype=np.float32)
wave = 15.0 * np.sin(map_x / 50.0) # You can adjust wave strength and frequency
map_y += wave
distorted = cv2.remap(img, map_x, map_y, interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_REFLECT)
return Image.fromarray(distorted)
|