圖片的加法運算:
常用函數:+,add(),addWeighted()
#include"opencv2/opencv.hpp"
#include<iostream>
using namespace cv;
using namespace std;
void main()
{
Mat img1 = imread("1.jpg");
Mat img2 = imread("2.jpg");
Mat dst;
//相加圖片的尺寸必須相同!!
//②add(img1,img2,dst);①Mat dst = img1 + img2;
addWeighted(img1,0.5,img2,0.5,0,dst);//權重各位0.5
imshow("img1",img1);
imshow("img2",img2);
imshow("dst",dst);
//輸出座標(10,10)的藍色通道的像素值
cout << "img1:" <<int(img1.at<Vec3b>(10, 10)[0]) << endl;//Vec3b是一種短向量的數據類型(3通道uchar類型的矩陣)
cout << "img2:" <<int(img2.at<Vec3b>(10, 10)[0])<< endl;
cout << "dst:" <<int(dst.at<Vec3b>(10, 10)[0]) << endl;
waitKey(0);
}