The arithmetic operation of the pattern.
#-*-Coding:utf-8-*-"" "Created on Wed Sep-11:54:47 2016@author:administrator" "" "" Arithmetic (arithmetic) Operations on Imag Escv2.add (), cv2addweighted () ' Import numpy as Npimport cv2 ' ' There is a difference between OpenCV addition and NumPy Addi tion. OpenCV addition is a saturated operation and Numpy addition is a modulo operation. " x = Np.uint8 ([+]) y = np.uint8 ([10]) # Only when the result is more than 255 print (Cv2.add (x, y) # 250+10=260=>255print (x+y) # 250+ 10=260%256 = 4# Image blending# DST = x*img1 + y*img2 + zimg1 = cv2.imread (' ml.png ') Img2 = Cv2.imread (' opencv_logo.png ') # Specify picture size = (x, x) img1 = Cv2.resize (img1,size) img2= cv2.resize (img2, size) # It can be understood that the first picture accounts for 70% of the weight, the second 30%, the last 0, is a constant term DST = cv2.addweighted (img1,0.7,img2,0.3,0) cv2.imshow (' DST ', DST) cv2.waitkey (0) cv2.destroyallwindows ()
The output is as follows (Figure ugly ignore ... Document not found):
Python opencv--arithmetic