Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to change brightness of an image? (Increase or Decrease)

I want to basically reduce brightness of an image

Method 1 source

mImage = cv2.imread('image.jpg')

hsvImg = cv2.cvtColor(mImage,cv2.COLOR_BGR2HSV)

value = 90

vValue = hsvImg[...,2]
hsvImg[...,2]=np.where((255-vValue)<value,255,vValue+value)

plt.subplot(111), plt.imshow(cv2.cvtColor(hsvImg,cv2.COLOR_HSV2RGB))
plt.title('test'), plt.xticks([]), plt.yticks([])
plt.show()

which gives a very weird bright effect

Method 2 Source answer in comments of the correct answer

image= cv2.add(image,np.array([50.0]))

Suppose to increase the brightness of the image by 50% have no idea how.

Method 3 source Using gamma

invGamma = 1.0 / gamma
table = np.array([((i / 255.0) ** invGamma) * 255
    for i in np.arange(0, 256)]).astype("uint8")

# apply gamma correction using the lookup table
cv2.LUT(image, table)

Method 4 source

Changing the contrast and brightness of an image, in the documentation is in C++ couldn't replecate or should be same as Method 3 I have no idea

According to Gamma vs brightness - any difference?

They two distinct terms.

Method 2 and Method 3 seems to work even when reducing the light intensity

Which method will not wash out the colours and only reduce the intensity of light is what I would like to know?