Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions digital_image_processing/change_contrast.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
from PIL import Image


def change_contrast(img: Image, level: float) -> Image:
def change_contrast(img: Image, level: int) -> Image:
"""
Function to change contrast
"""
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
every bit.
"""
return 128 + factor * (c - 128)
return int(128 + factor * (c - 128))

return img.point(contrast)

Expand Down