Make LUTs more realistic
This commit is contained in:
parent
70917e26c3
commit
8bc329293b
2 changed files with 71 additions and 22 deletions
File diff suppressed because one or more lines are too long
|
|
@ -4,17 +4,39 @@ from .random import random
|
|||
from .interpolate import interpolate, INTERPOLATION_TYPE
|
||||
|
||||
|
||||
def get_edit_points(variance: float, count: int) -> List[float]:
|
||||
def get_random_saturation_per_hue_lut(
|
||||
variance: float = 0.4, count: int = 12
|
||||
) -> List[int]:
|
||||
edit_points = [random(-variance, variance) + 1 for _ in range(count)]
|
||||
|
||||
return [
|
||||
random(i / (count - 1) - variance, i / (count - 1) + variance)
|
||||
for i in range(count)
|
||||
interpolate(edit_points, i / 255, type="cubic")
|
||||
for i in np.linspace(0, 255, 256)
|
||||
]
|
||||
|
||||
|
||||
def get_colour_lut(
|
||||
variance=0.1, count=5, type: INTERPOLATION_TYPE = "cubic"
|
||||
def get_random_brightness_lut(
|
||||
variance: float = 0.2,
|
||||
count: int = 6,
|
||||
type: INTERPOLATION_TYPE = "linear",
|
||||
min_spectrum_size: float = 0.6,
|
||||
max_spectrum_size: float = 1.15,
|
||||
) -> List[int]:
|
||||
edit_points = get_edit_points(variance=variance, count=count)
|
||||
spectrum_size = np.random.uniform(min_spectrum_size, max_spectrum_size)
|
||||
spectrum_start = np.random.uniform(0, max(0, 1 - spectrum_size))
|
||||
edit_points = sorted(
|
||||
[
|
||||
spectrum_start,
|
||||
*[
|
||||
spectrum_start
|
||||
+ i * spectrum_size / (count - 2)
|
||||
+ np.random.uniform(-variance, variance)
|
||||
for i in range(1, count - 2)
|
||||
],
|
||||
spectrum_start + spectrum_size,
|
||||
]
|
||||
)
|
||||
|
||||
return [
|
||||
round(interpolate(edit_points, i / 255, type=type) * 255)
|
||||
for i in np.linspace(0, 255, 256)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue