溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

圖像混合

發布時間:2020-08-03 03:59:04 來源:網絡 閱讀:524 作者:zgh0816 欄目:編程語言

本章主要學習addWeighted(src1,alpha,src2,beta,gamma,dst,dtype=-1)這個函數,

參數1:輸入圖像Mat-src1;

參數2:輸入圖像Mat-src1的alpha值;

參數3:輸入圖像Mat-src2;

參數4:輸入圖像Mat-src2的alpha值(1-alpha);

參數5:gamma值,默認為0;

參數6:輸出混合圖像

函數功能將兩幅圖像相加,注意兩幅圖像類型必須相同,否則相加會出現錯誤,這個API是opencv自帶的,也可以直接用add(src1,src2,dst,Mat()),來操作,效果沒有addWeighted

源代碼如下:

#include <opencv2/opencv.hpp>

#include <iostream>

using namespace cv;

using namespace std;

int main(int argc, char** argv) 

{

Mat src1, src2, dst;

src1 = imread("C:/Users/Administrator/Desktop/3.jpg");

src2 = imread("C:/Users/Administrator/Desktop/4.jpg");

if (!src1.data)

{

cout << "the image src1 could not load..." << endl;

return -1;

}

if (!src2.data)

{

cout << "the image src2 could not load..." << endl;

return -1;

}

double alpha = 0.5;

if (src1.rows == src2.rows && src1.cols == src2.cols && src1.type() == src2.type())

{

addWeighted(src1, alpha, src2, (1.0 - alpha), 0.0, dst, -1);//圖像相加

//add(src1, src2, dst, Mat());

imshow("src1", src1);

imshow("src2", src2);

imshow("blend image", dst);

imwrite("C:/Users/Administrator/Desktop/blend image.jpg", dst);

}

else {

printf("could not blend images,the size of image is not same\n");

return -1;

}

waitKey(0);

return 0;

}

圖像混合圖像混合圖像混合

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女