Adjust the brightness and/or contrast of an image :param image: OpenCV BGR image :param contrast: Float, contrast adjustment with 0 meaning no change :param brightness: Float, brightness adjustment with 0 meaning no change
(image, brightness=0., contrast=0.)
| 302 | |
| 303 | |
| 304 | def adjust_brightness_contrast(image, brightness=0., contrast=0.): |
| 305 | """ |
| 306 | Adjust the brightness and/or contrast of an image |
| 307 | |
| 308 | :param image: OpenCV BGR image |
| 309 | :param contrast: Float, contrast adjustment with 0 meaning no change |
| 310 | :param brightness: Float, brightness adjustment with 0 meaning no change |
| 311 | """ |
| 312 | beta = 0 |
| 313 | # See the OpenCV docs for more info on the `beta` parameter to addWeighted |
| 314 | # https://docs.opencv.org/3.4.2/d2/de8/group__core__array.html#gafafb2513349db3bcff51f54ee5592a19 |
| 315 | return cv2.addWeighted(image, |
| 316 | 1 + float(contrast) / 100., |
| 317 | image, |
| 318 | beta, |
| 319 | float(brightness)) |
no outgoing calls
no test coverage detected
searching dependent graphs…