Allow parametrizing gamma

This commit is contained in:
kris 2021-05-28 11:24:05 +01:00
parent 07a358d49b
commit a593639606
1 changed files with 3 additions and 3 deletions

View File

@ -18,8 +18,8 @@ def srgb_to_linear(im: np.ndarray) -> np.ndarray:
return (np.clip(rgb_linear, 0.0, 1.0) * 255).astype(np.float32)
def linear_to_srgb(im: np.ndarray) -> np.ndarray:
srgb = linear_to_srgb_array(im / 255.0, gamma=2.4)
def linear_to_srgb(im: np.ndarray, gamma=2.4) -> np.ndarray:
srgb = linear_to_srgb_array(im / 255.0, gamma=gamma)
return (np.clip(srgb, 0.0, 1.0) * 255).astype(np.float32)
@ -41,4 +41,4 @@ def resize(image: Image, x_res, y_res, srgb_output: bool = False) -> Image:
return Image.fromarray(
linear_to_srgb(np.array(res, dtype=np.float32)).astype(np.uint8))
else:
return res
return res