How to fast change image brightness with python + OpenCV?

前端 未结 12 845
感动是毒
感动是毒 2020-12-05 10:42

I have a sequence of images. I need to average brightness of these images.

First example (very slow):

img = cv2.imread(\'test.jpg\')         


        
12条回答
  •  独厮守ぢ
    2020-12-05 11:15

    Might be too old but I use cv.covertTo which works for me

    Mat resultBrightImage;    
    origImage.convertTo(resultBrightImage, -1, 1, percent); // Where percent = (int)(percent_val/100)*255, e.g., percent = 50 to increase brightness by 50%
    

    convertTo uses saturate_cast at the end to avoid any overflows. I don't use Python and the above is in C++ but I hope it is easily convertible in Python and hope it helps

提交回复
热议问题