Skip to content

Instantly share code, notes, and snippets.

@vardanagarwal
Created February 10, 2020 20:38
Show Gist options
  • Save vardanagarwal/4ef33e656fb7ad033ac719dd23e92480 to your computer and use it in GitHub Desktop.
Save vardanagarwal/4ef33e656fb7ad033ac719dd23e92480 to your computer and use it in GitHub Desktop.
import cv2
import numpy as np
img = cv2.imread('Paris.jpg')
original = img.copy()
hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) # convert image to HSV color space
hsv = np.array(hsv, dtype = np.float64)
hsv[:,:,1] = hsv[:,:,1]*1.25 # scale pixel values up for channel 1
hsv[:,:,1][hsv[:,:,1]>255] = 255
hsv[:,:,2] = hsv[:,:,2]*1.25 # scale pixel values up for channel 2
hsv[:,:,2][hsv[:,:,2]>255] = 255
hsv = np.array(hsv, dtype = np.uint8)
img = cv2.cvtColor(hsv, cv2.COLOR_HSV2BGR) # converting back to BGR used by OpenCV
cv2.imshow("original", original)
cv2.imshow("Output", img)
cv2.waitKey(0)
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment