Add editing methods
This commit is contained in:
commit
f7d9c0193d
12 changed files with 161 additions and 0 deletions
11
editor/operations/add_noise.py
Normal file
11
editor/operations/add_noise.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
|
||||
def add_noise(img: Image, alpha: float) -> Image:
|
||||
img = img.convert("RGB")
|
||||
width, height = img.size
|
||||
random_colors = np.random.randint(0, 256, (height, width, 3), dtype=np.uint8)
|
||||
random_img = Image.fromarray(random_colors, mode="RGB")
|
||||
result = Image.blend(img, random_img, alpha)
|
||||
return result
|
||||
Loading…
Add table
Add a link
Reference in a new issue