Increase image brightness without overflow

Viewed 15106

I got a problem when trying to increase image brightness.

Here is the origin image:

enter image description here

The image I wanted to get is like this:

enter image description here

Now to increase the brightness with the following code:

    image = cv2.imread("/home/wni/vbshare/tmp/a4_index2.png",0)

    if sum(image[0])/len(image[0])<200:
        new = np.where((255-image)<image,255,image*2)
    else:
        new = image
    return new

And, I got the following image:

enter image description here

So, seems brightness of some points overflowed.

And I tried to change the threshold from 200 to some other number, e.g. 125, 100, 140 .etc However, the image brightness stays either almost same dark or overflow.

Env:

Python: 2.7.10

Opencv: 3.2.0

Any suggestion for this is appreciated.

Thanks.

2 Answers
Related