Image blending learning. Using weighted function to learn OPENCV basic operation

Source: Internet
Author: User

1#include <opencv2/opencv.hpp>
2#include <iostream>
3usingnamespaceStd
4usingnamespaceCv
5//----------------------Fusion function ——-------
6BOOLRoi_addimg ()
7{
8Mat srcimage = Imread ("3.jpg");
9Mat logoimage = Imread ("1.jpg");
Ten//detecting whether to read picture data
Oneif(!srcimage.data)
A{
-cout<<"no src data"<<endl;
-}
theif(!logoimage.data)
-{
-cout<<"No Logo data"<<endl;
-}
+//define a mat type and specify ROI area
-Mat roiimage = Srcimage (Rect (0,0, logoimage.cols,logoimage.rows));
+//Add Weights
A Addweighted (Roiimage,0.7, Logoimage,0.6,0., roiimage);
atNamedwindow ("..");
-Imshow ("..", srcimage);
-Mat D (Srcimage,rect (Ten,Ten, -, -));
-Namedwindow (".");
-Imshow (".", D);
-Mat F = Srcimage (Range ( -, -), Range ( -, -));
inNamedwindow ("1.");
-Imshow ("1.", F);
toImwrite ("123.jpg", srcimage);
+returntrue;
-}

1 #include <iostream>

2#include <opencv2/opencv.hpp>
3usingnamespaceStd
4usingnamespaceCv
5BOOLRoi_addimg ();
6BOOLRoi_addimage ()
7{
8Mat srcimage = Imread ("1.jpg");
9Mat logoimage = Imread ("2.jpg");
Tenif(!srcimage.data)
One{
Acout<<"false! No Creimage"<<endl;
-returnfalse;
-}
theif(!logoimage.data)
-{
-cout<<"SB No Logoimage"<<endl;
-returnfalse;
+}
-Mat Imageroi = Srcimage (Rect ( $, -, logoimage.cols,logoimage.rows));
+//Add mask Copy to Roi must be grayscale image
AMat mask = Imread ("2.jpg",0);
atLogoimage.copyto (Imageroi,mask);
-//Mat imageROI1;
-    //addweighted (imageroi,0.7,logoimage,0.3,0.0,imageroi);
-Namedwindow ("...");
-Imshow ("...", srcimage);
-Waitkey (1);
inreturntrue;
-}
tovoidMain ()
+{
-if(Roi_addimage () &&roi_addimg ())
thecout<<"Good"<<endl;
*Waitkey (0);
$
Panax Notoginseng//return Roi_addimage ();
-}

Image blending learning. Using weighted function to learn OPENCV basic operation

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.