Da Nio
Da Nio

Reputation: 302

How to change the exposure of the photo in OpenCV

Is there a technique that allows you to change the exposure of a photo? I would like to know if there is a "generic" formula for having different degrees of exposure, for example:

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

Code would be very welcome.

Upvotes: 2

Views: 9105

Answers (1)

heLomaN
heLomaN

Reputation: 1804

As the page @JDevr mentioned, just read the Gamma correction part. I'm afraid you must manually adjust the gamma value, or just assume it. Sample code in python as followings:

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)

Upvotes: 4

Related Questions