wave1 / distort.py
Janeka's picture
Create distort.py
4b9cecd verified
raw
history blame contribute delete
458 Bytes
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)