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?
what if you just multiply it with some factor, like???@berak I am working on a wide range of real world images hard to control the exposer so
0.8
seems to have no effect very similar to1.0
yea, sorry. the 1st question should have been: why are you doing this ? what is the context ?
@berak Since the colour were getting washed out from the images on decreasing the brightness, I tried to enhance the colour in that particular image. The result were good, but I need to find a way to enhance colour of an image to make it more vibrant. I will put up a different question for this
@berakHow to make an image more vibrant in colour using OpenCV?