Gamma变换
#Gamma变化
import cv2
import numpy as np
img = cv2.imread('test.jpg')
def adjust_gamma(image,gamma = 1.0):
invGamma = 1.0/gamma
table = []
for i in range(256):
table.append(((i/255.0)**invGamma)*255)
table = np.array(table).astype("uint8")
print(table)
return cv2.LUT(image,table)
img_gamma = adjust_gamma(img,2)
print(img_gamma)
cv2.imshow("img",img)
cv2.imshow("img_gamma",img_gamma)
cv2.waitKey(0)
cv2.destoryAllWindows()
代码中使用的原图test.jpg
还没有评论,来说两句吧...