mirror of
https://github.com/KrisKennaway/ii-pix.git
synced 2024-11-07 22:06:34 +00:00
Allow parametrizing gamma
This commit is contained in:
parent
07a358d49b
commit
a593639606
6
image.py
6
image.py
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user