标签:style blog http io ar color os sp strong
>_<" 这次主要是图像叠加的基本操作:
>_<" cv::addWeighted(imageROI, 1.0, logo, 0.6, 0, imageROI);即:目标像素=src1*alpha+src2*beta
1 #include <iostream> 2 #include <opencv2/highgui/highgui.hpp> 3 #include <opencv2/core/core.hpp> 4 5 using namespace cv; 6 using namespace std; 7 8 int main(){ 9 cv::Mat image = cv::imread("fruits.jpg"); 10 cv::Mat logo = cv::imread("logo.png"); 11 cv::Mat mask = cv::imread("logo.png",0); 12 cv::Mat imageROI; 13 imageROI = image(cv::Rect(10,10,logo.cols,logo.rows)); 14 //logo.copyTo(imageROI,mask);//这个函数可以复制图像到另一个图像或矩阵上,可选参数是掩码 15 //void addWeighted(InputArray src1, double alpha, InputArray src2, double beta, double gamma, OutputArray dst, int dtype=-1) 16 //目标像素=src1*alpha+src2*beta 17 cv::addWeighted(imageROI, 1.0, logo, 0.6, 0, imageROI); 18 //cv::namedWindow("result"); 19 cv::imshow("result-image",image); 20 cv::imshow("result-mask",mask); 21 cv::waitKey(); 22 return 0; 23 }
标签:style blog http io ar color os sp strong
原文地址:http://www.cnblogs.com/zjutlitao/p/4126638.html