![]() ![]() # Otherwise, adjust brightness to get the target brightness Yves Daoust suggested keeping beta = 0, so I adjusted alpha = minimum_brightness / brightness to get the target brightness: ratio = brightness / minimum_brightness Kanat suggested: bright_img = cv2.convertScaleAbs(img, alpha = 1, beta = 255 * (minimum_brightness - brightness))Īnd the result is better but still has a veil: Has anyone succeeded in adjusting brightness automatically to a target? Update I could do it with either a gamma correction and/or histogram equalization for maybe a more natural result, but I don't see an easy way to get the target brightness other than trial-and-error. ![]() If I do it by hand, for example in Photoshop with a brightness adjustment at 150, the result seems alright:īut, this is not automatic and does not give the target brightness. I can avoid this effect by using bias only: bright_img = cv2.convertScaleAbs(img, alpha = 1, beta = 128) To bring it to 66%, for example, I do: minimum_brightness = 0.66īright_img = cv2.convertScaleAbs(img, alpha = alpha, beta = 255 * (1 - alpha))Īnd I get an image that seems to have a 50% transparency veil: I calculate the brightness with: import cv2īrightness = numpy.sum(img) / (255 * cols * rows)Īnd I get an average brightness of 35%. I want to adjust the brightness of an image to a certain value in OpenCV.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |