Remove editor module

This commit is contained in:
Andras Schmelczer 2024-06-22 18:37:24 +01:00
parent e5959268c1
commit c966866abc
No known key found for this signature in database
GPG key ID: FC8F2C3D3D1A718C
37 changed files with 7752 additions and 7345 deletions

View file

@ -0,0 +1,33 @@
from PIL import Image, ImageEnhance
from utils import random
from operations import (
add_noise,
add_random_colour_spill,
get_random_gamma,
adjust_gamma,
apply_pixel_shader,
get_random_brightness_lut,
get_random_saturation_per_hue_lut,
)
import numpy as np
def random_edit(img: Image, seed: int = 42) -> Image:
np.random.seed(seed)
img = img.convert("RGB")
img = ImageEnhance.Contrast(img).enhance(random(0.5, 1.5))
img = adjust_gamma(img, get_random_gamma())
img = img.convert("HSV")
saturation_lut = get_random_saturation_per_hue_lut()
brightness_lut = get_random_brightness_lut()
img = apply_pixel_shader(
img, lambda h, s, v: (h, round(s * saturation_lut[h]), brightness_lut[v])
)
img = img.convert("RGB")
img = add_random_colour_spill(img, 0.2)
img = add_noise(img, random(0, 0.1))
return img