1.常见的API
2.完整代码:
import cv2
import numpy as np
dog = cv2.imread("image/dog.png")
bus = cv2.imread("image/bus.jpg")
#位运算操作要求两张图片的大小和通道数一致
new_bus = cv2.resize(bus,(dog.shape[:-1][::-1]))
#位运算是将对应像素上的数值变成二进制,进而对每一位进行相应的操作
#因此一个数字 x进行非操作后得到的值是255-x
#非运算
new_img = cv2.bitwise_not(dog)
#与运算
new_img = cv2.bitwise_and(dog,new_bus)
#或运算
new_img = cv2.bitwise_or(dog,new_bus)
#异或运算
new_img = cv2.bitwise_xor(dog,new_bus)
cv2.imshow("show",new_img)
cv2.waitKey(0)
cv2.destroyAllWindows()