mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-30 16:31:08 +00: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…
Reference in New Issue
Block a user