Python opencv--arithmetic

Source: Internet
Author: User
Tags arithmetic

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.