mirror of
https://hub.njuu.cf/TheAlgorithms/Python.git
synced 2023-10-11 13:06:12 +08:00
parent
9b3f7c36d0
commit
5903948cf3
@ -11,18 +11,18 @@ flake8 : True
|
|||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
|
|
||||||
def change_contrast(img: Image, level: float) -> Image:
|
def change_contrast(img: Image, level: int) -> Image:
|
||||||
"""
|
"""
|
||||||
Function to change contrast
|
Function to change contrast
|
||||||
"""
|
"""
|
||||||
factor = (259 * (level + 255)) / (255 * (259 - level))
|
factor = (259 * (level + 255)) / (255 * (259 - level))
|
||||||
|
|
||||||
def contrast(c: int) -> float:
|
def contrast(c: int) -> int:
|
||||||
"""
|
"""
|
||||||
Fundamental Transformation/Operation that'll be performed on
|
Fundamental Transformation/Operation that'll be performed on
|
||||||
every bit.
|
every bit.
|
||||||
"""
|
"""
|
||||||
return 128 + factor * (c - 128)
|
return int(128 + factor * (c - 128))
|
||||||
|
|
||||||
return img.point(contrast)
|
return img.point(contrast)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user