self_example/TensorFlow_eaxmple/OpenCV_try/图像色调的调整.py

14 lines
727 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import cv2
img=cv2.imread('lena.jpg')
img_hsv=cv2.cvtColor(img,cv2.COLOR_BGR2HSV)
turn_green_hsv=img_hsv.copy()
less_color_hsv=img_hsv.copy()
'''等式左边的参数方括号中第一个和第二个参数分别代表图像矩阵的坐标第三个参数代表HSV的选择0指的是色调1指的是饱和度2指的是明暗度'''
turn_green_hsv[:,:,0]=(turn_green_hsv[:,:,0]-30)%180
less_color_hsv[:,:,0]=less_color_hsv[:,:,0]*0.6
#turn_green_hsv[:,:,1]=(turn_green_hsv[:,:,1]-30)%180
#turn_green_hsv[:,:,2]=(turn_green_hsv[:,:,2]-30)%180
turn_green_img1=cv2.cvtColor(less_color_hsv,cv2.COLOR_HSV2BGR)
turn_green_img=cv2.cvtColor(turn_green_hsv,cv2.COLOR_HSV2BGR)
cv2.imshow("test",turn_green_img1)
cv2.waitKey(0)