Add gamma
This commit is contained in:
parent
388d3d3ce3
commit
8277768df8
2 changed files with 70 additions and 0 deletions
58
src/editor/operations/gamma.ipynb
Normal file
58
src/editor/operations/gamma.ipynb
Normal file
File diff suppressed because one or more lines are too long
12
src/editor/operations/gamma.py
Normal file
12
src/editor/operations/gamma.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
import numpy as np
|
||||
from random import choice
|
||||
from PIL import Image
|
||||
|
||||
|
||||
def adjust_gamma(img: Image, gamma: float) -> Image:
|
||||
return img.point(lambda x: (x / 255) ** gamma * 255)
|
||||
|
||||
|
||||
def get_random_gamma() -> float:
|
||||
gamma = np.random.beta(1, 2) * 0.6
|
||||
return 1 / (1 + gamma) if choice([True, False]) else (gamma + 1)
|
||||
Loading…
Add table
Add a link
Reference in a new issue