Opencv-python using the original image and mask to implement the cutout

Source: Internet
Author: User

1, first

Original: Test1.png

Mask diagram: Test-mask.png

Result diagram: Mask.png

2. Code part

ImportCv2 fromPILImportImageImportNumPy as Npyuantu="Test1.png"masktu="Test1-mask.png"#overlay pictures with OpenCVIMG1 =Cv2.imread (yuantu) Img2=Cv2.imread (masktu) Alpha= 0.5Meta= 1-Alphagamma=0#cv2.imshow (' img1 ', IMG1)#cv2.imshow (' Img2 ', Img2)#image = cv2.addweighted (Img1,alpha,img2,meta,gamma)Image =Cv2.add (IMG1, Img2) cv2.imshow ('Image', image) Cv2.waitkey (0) cv2.destroyallwindows () Cv2.imwrite ("./mask.png", image)

Opencv-python using the original image and mask to implement the cutout

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.