MCPcopy Create free account
hub / github.com/TheAlgorithms/Python / change_contrast

Function change_contrast

digital_image_processing/change_contrast.py:14–27  ·  view source on GitHub ↗

Function to change contrast

(img: Image, level: int)

Source from the content-addressed store, hash-verified

12
13
14def change_contrast(img: Image, level: int) -> Image:
15 """
16 Function to change contrast
17 """
18 factor = (259 * (level + 255)) / (255 * (259 - level))
19
20 def contrast(c: int) -> int:
21 """
22 Fundamental Transformation/Operation that'll be performed on
23 every bit.
24 """
25 return int(128 + factor * (c - 128))
26
27 return img.point(contrast)
28
29
30if __name__ == "__main__":

Callers 1

change_contrast.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected