如何在OpenCV中更改照片的曝光度

时间:2019-08-01 12:59:42

标签: python image opencv image-processing exposure

有没有一种技术可以改变照片的曝光度? 我想知道是否存在一个具有不同暴露程度的“通用”公式,例如:

1. Strongly underexposed
2. Underexposed
3. Correct exposure
4. Overexposed
5. Strongly overexposed

代码非常受欢迎。

1 个答案:

答案 0 :(得分:0)

正如@JDevr页面中提到的,只需阅读Gamma校正部分。恐怕您必须手动调整伽玛值,或只是假设它。 python中的示例代码如下:

def gamma_trans(img, gamma):
    gamma_table=[np.power(x/255.0,gamma)*255.0 for x in range(256)]
    gamma_table=np.round(np.array(gamma_table)).astype(np.uint8)
    return cv2.LUT(img,gamma_table)

image_gamma_correct=gamma_trans(image,value_of_gamma)