Created
February 11, 2020 16:32
-
-
Save vardanagarwal/a640ac9490a1ee8f636733d5b449cd6f to your computer and use it in GitHub Desktop.
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
import cv2 | |
def gamma_function(channel, gamma): | |
invGamma = 1/gamma | |
table = np.array([((i / 255.0) ** invGamma) * 255 | |
for i in np.arange(0, 256)]).astype("uint8") | |
channel = cv2.LUT(channel, table) | |
return channel | |
img = cv2.imread('Paris.jpg') | |
original = img.copy() | |
img[:, :, 0] = gamma_function(img[:, :, 0], 1.25) | |
img[:, :, 2] = gamma_function(img[:, :, 2], 0.75) | |
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) | |
hsv[:, :, 1] = gamma_function(hsv[:, :, 1], 0.8) | |
img = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) | |
cv2.imshow('Original', original) | |
cv2.imshow('Winter', img) | |
cv2.waitKey(0) | |
cv2.destroyAllWindows() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment