Skip to content

Instantly share code, notes, and snippets.

@hav4ik
Last active June 30, 2020 20:20
Show Gist options
  • Save hav4ik/34a668b25f00885a052905336ad658e5 to your computer and use it in GitHub Desktop.
Save hav4ik/34a668b25f00885a052905336ad658e5 to your computer and use it in GitHub Desktop.
This is for my medium article
# Somehow I found the value of `gamma=1.2` to be the best in my case
def adjust_gamma(image, gamma=1.2):
# build a lookup table mapping the pixel values [0, 255] to
# their adjusted gamma values
invGamma = 1.0 / gamma
table = np.array([((i / 255.0) ** invGamma) * 255
for i in np.arange(0, 256)]).astype("uint8")
# apply gamma correction using the lookup table
return cv2.LUT(image, table)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment