-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
59 lines (51 loc) · 1.42 KB
/
main.cpp
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
53
54
55
56
57
58
59
/*
* main.cpp
*
* Created on: 24/mar/2015
* Author: nicola pierazzo <nicola.pierazzo@cmla.ens-cachan.fr>
*/
#include <iostream>
#include <iterator>
#include <fstream>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <utility>
#include "Image.hpp"
#include "Utils.hpp"
#include "DemoUtils.hpp"
#include "DA3D.hpp"
using std::cerr;
using std::endl;
using utils::pick_option;
using utils::read_image;
using utils::save_image;
using utils::isMonochrome;
using utils::makeMonochrome;
using da3d::Image;
using da3d::DA3D;
int main(int argc, char **argv) {
bool usage = static_cast<bool>(pick_option(&argc, argv, "h", nullptr));
if (usage || argc < 4) {
cerr << "usage: " << argv[0] << " noisy guide sigma output" <<
endl;
return EXIT_FAILURE;
}
#ifndef _OPENMP
cerr << "Warning: OpenMP not available. The algorithm will run in a single" <<
" thread." << endl;
#endif
Image input = read_image(argv[1]);
Image guide = read_image(argv[2]);
float sigma = atof(argv[3]);
// DA3D doesn't work if a color image has monochromatic noise
if (input.channels()>1 && isMonochrome(input)) {
cerr << "Warning: input color image has monochromatic noise! " <<
"Converting to monochrome." << endl;
input = makeMonochrome(input);
guide = makeMonochrome(guide);
}
Image output = DA3D(input, guide, sigma);
save_image(output, argc > 4 ? argv[4] : "-");
return EXIT_SUCCESS;
}