-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexposureStack.cpp
More file actions
52 lines (38 loc) · 1.01 KB
/
exposureStack.cpp
File metadata and controls
52 lines (38 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <opencv2/opencv.hpp>
#include "opencv2/xphoto.hpp"
int main( int argc, char *argv[] ){
if( argc < 3) {
std::cout << "Proper usage is" << argv[0] << " <filename1> ... <filenameN>\r\n";
return -1;
}
std::vector<cv::Mat> aFrames;
cv::Mat stackedFrames;
for( int i = 1; i < argc; i++){
//Load image
aFrames.push_back( cv::imread( argv[i]) );
if(i != 1){
//Calculate image weights
double beta = 1.0 / i;
double alpha = 1.0 - beta;
//Now stack them
if(i < 2) continue;
else if(i == 2)
addWeighted( aFrames[0], alpha, //Frame and weight
aFrames[1], beta, //Frame and weight
0.0, //Gamma
stackedFrames, //Destination
-1); //dtype
else
addWeighted( stackedFrames, alpha,
aFrames[i-1], beta,
0.0,
stackedFrames,
-1);
}
}
std::string newname = argv[1];
newname = newname.substr(0, newname.find_last_of("/") + 1);
newname += "stackedImage.tif";
cv::imwrite(newname, stackedFrames);
}