1 #include <opencv2/opencv.hpp>
2 #include <iostream>
3 using namespace std;
4 using namespace cv;
5 //----------------------融合函数——-------
6 bool ROI_Addimg()
7 {
8 Mat srcImage = imread("3.jpg");
9 Mat logoImage = imread("1.jpg");
//检测是否读取到图片数据
if (!srcImage.data)
{
cout<<"no src data"<<endl;
}
if (!logoImage.data)
{
cout<<"no logo data"<<endl;
}
//定义一个Mat类型并指定ROI区域
Mat ROIimage = srcImage(Rect(,,logoImage.cols,logoImage.rows));
//添加权重
addWeighted(ROIimage,0.7,logoImage,0.6,.,ROIimage);
namedWindow("..");
imshow("..",srcImage);
Mat D(srcImage,Rect(,,,));
namedWindow(".");
imshow(".",D);
Mat F = srcImage(Range(,), Range(,));
namedWindow("1.");
imshow("1.",F);
imwrite("123.jpg",srcImage);
return true;
} 1 #include <iostream> 2 #include <opencv2/opencv.hpp>
3 using namespace std;
4 using namespace cv;
5 bool ROI_Addimg();
6 bool ROI_Addimage()
7 {
8 Mat srcImage = imread("1.jpg");
9 Mat logoImage = imread("2.jpg");
if (!srcImage.data)
{
cout<<"false! no creImage"<<endl;
return false;
}
if (!logoImage.data)
{
cout<<"SB no logoImage"<<endl;
return false;
}
Mat imageROI = srcImage(Rect(,,logoImage.cols,logoImage.rows));
//加掩模复制到ROI 必须是灰度图像
Mat mask = imread("2.jpg",);
logoImage.copyTo(imageROI,mask);
//Mat imageROI1;
//addWeighted(imageROI,0.7,logoImage,0.3,0.0,imageROI);
namedWindow("...");
imshow("...",srcImage);
waitKey();
return true;
}
void main()
{
if(ROI_Addimage()&&ROI_Addimg())
cout<<"good"<<endl;
waitKey();
//return ROI_Addimage();
}