猿代码 — 科研/AI模型/高性能计算
0

天河超算:opencv, 编译,AddingImages.cpp

摘要: 1)/*** @file AddingImages.cpp* @brief Simple linear blender ( dst = alpha*src1 + beta*src2 )* @author OpenCV team*/#include "opencv2/imgcodecs.hpp"#include "opencv2/highgui.hpp"#include iostreamusing ...
1)
/**
 * @file AddingImages.cpp
 * @brief Simple linear blender ( dst = alpha*src1 + beta*src2 )
 * @author OpenCV team
 */
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include <iostream>

using namespace cv;

// we're NOT "using namespace std;" here, to avoid collisions between the beta variable and std::beta in c++17
using std::cin;
using std::cout;
using std::endl;

/**
 * @function main
 * @brief Main function
 */
int main( void )
{
   double alpha = 0.5; double beta; double input;

   Mat src1, src2, dst;

   /// Ask the user enter alpha
   cout << " Simple Linear Blender " << endl;
   cout << "-----------------------" << endl;
   cout << "* Enter alpha [0.0-1.0]: ";
   cin >> input;

   // We use the alpha provided by the user if it is between 0 and 1
   if( input >= 0 && input <= 1 )
     { alpha = input; }

   //![load]
   /// Read images ( both have to be of the same size and type )
   src1 = imread( samples::findFile("LinuxLogo.jpg") );
   src2 = imread( samples::findFile("WindowsLogo.jpg") );
   //![load]

   if( src1.empty() ) { cout << "Error loading src1" << endl; return EXIT_FAILURE; }
   if( src2.empty() ) { cout << "Error loading src2" << endl; return EXIT_FAILURE; }

   //![blend_images]
   beta = ( 1.0 - alpha );
   addWeighted( src1, alpha, src2, beta, 0.0, dst);
   //![blend_images]

   //![display]
  //  imshow( "Linear Blend", dst );
   imwrite("aaa.jpg", dst);
   waitKey(0);
   //![display]

   return 0;
}

2)
其实就是两张图片相加,由于是Linux,远程,所以改成了保存图片,使用imwrite()
其实也很简单啊


3)效果如下:



说点什么...

已有0条评论

最新评论...

本文作者
2023-11-15 22:38
  • 0
    粉丝
  • 491
    阅读
  • 0
    回复
资讯幻灯片
热门评论
热门专题
排行榜
Copyright   ©2015-2023   猿代码-超算人才智造局 高性能计算|并行计算|人工智能      ( 京ICP备2021026424号-2 )