Last active
June 30, 2020 20:20
-
-
Save hav4ik/34a668b25f00885a052905336ad658e5 to your computer and use it in GitHub Desktop.
This is for my medium article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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