opencv to achieve image arithmetic and logic operations, and image fusion function (brightness and contrast)

Math does not say, anyway, is the use of two identical pictures cv.add (), cv.substract (), cv.multiply (), cv.divide (), etc. to achieve 

Logical operation is cv.bitewise_and (), cv.bitewise_or (), etc.

#调节亮度
import cv2 as cv
import numpy as np

def control_bright(image, alpha):
    blank = np.zeros(shape=image.shape, dtype=image.dtype)
    dst = cv.addWeighted(blank, 1-alpha, image, alpha, 0)
    cv.imshow("img", image)
    cv.moveWindow("img", 20, 20)
    cv.imshow("dst", dst)
    cv.waitKey(0)

img = cv.imread("d:/a.jfif")
cv.add()
control_bright(img, 2)

The above code for adjusting brightness and contrast of a picture function.

dst = cv.addWeighted (src1, alpha, src2, beta, gamma) of the parameters are as follows:

Function, as will be appreciated dst = src1 * alpha + src2 * beta + gamma

src1: first image

src2: Second image

alpha: The first image occupies weight

beta: The second image occupies weight

gamma: After image fusion for each pixel plus a gamma value.

Guess you like

Origin www.cnblogs.com/loubin/p/12290023.html