addWeighted函数的运用

 1 #include<opencv2\opencv.hpp>
 2 #include<iostream>
 3 #include<vector>
 4 using namespace cv;
 5 using namespace std;
 6 
 7 int main() {
 8     Mat image = imread("C:\\Users\\Nelsoner\\Desktop\\Camera Roll\\05.jpg");
 9     Mat logo = imread("C:\\Users\\Nelsoner\\Desktop\\Camera Roll\\001.jpg");
10 
11     Mat imageROI = image(Rect(image.cols- logo.cols, image.rows- logo.rows, logo.cols, logo.rows));
12     //Mat imageROI = image(Range(350,350+logo.rows),Range(800,800+logo.rows));  //效果同上
13     //将logo加到原图上
14     //addWeighted(imageROI, 1.0, logo, 1, 0., imageROI);
15 
16     //使用掩模,效果同上
17     Mat mask = imread("C:\\Users\\Nelsoner\\Desktop\\Camera Roll\\001.jpg");
18     logo.copyTo(imageROI,mask);
19     
20     namedWindow("hah");
21     imshow("hah",image);
22 
23     imwrite("C:\\Users\\Nelsoner\\Desktop\\Camera Roll\\加logo的图.jpg",image);
24     waitKey();
25     return 0;
26 }

 

 

posted @ 2017-04-16 14:00  蒋酱酱  阅读(4696)  评论(0编辑  收藏  举报