2

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.

petezurich
  • 9,280
  • 9
  • 43
  • 57
Da Nio
  • 302
  • 1
  • 6
  • 16
  • If you get photo from camera, could refer to [this](http://www.principiaprogramatica.com/2017/06/11/setting-manual-exposure-in-opencv/): `cap.set(cv2.CAP_PROP_EXPOSURE,-4)` – heLomaN Aug 01 '19 at 13:15
  • Im using static photo (.jpg) – Da Nio Aug 01 '19 at 13:16

1 Answers1

3

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)
heLomaN
  • 1,634
  • 2
  • 22
  • 33