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
|
#include <iostream>
#include <vector>
#include "opencv2/opencv.hpp"
#include "opencv2/photo/photo.hpp"
#include "cxxopts/src/cxxopts.hpp"
using namespace std;
using namespace cv;
int
main (int argc, char** argv)
{
cxxopts::Options opt(argv[0], " - Options");
opt.add_options()
("f,file", "file", cxxopts::value<string>())
("b,black_and_white", "image is black and white")
("h,hh", "h", cxxopts::value<float>()->default_value("3.0"))
("C,hColor", "hColor", cxxopts::value<float>()->default_value("3.0"))
("t,template_size", "template window size", cxxopts::value<int>()->default_value("7"))
("s,search_size", "search window size", cxxopts::value<int>()->default_value("21"))
("T,threads", "number of threads", cxxopts::value<int>()->default_value("1"))
("o,output", "output file", cxxopts::value<string>());
opt.parse(argc, argv);
auto& file = opt["f"].as<string>();
auto is_bw = opt.count("b");
auto& output = opt["o"].as<string>();
float h = opt["h"].as<float>();
float hColor = opt["C"].as<float>();
float template_size = opt["t"].as<int>();
float search_size = opt["s"].as<int>();
setNumThreads(opt["T"].as<int>());
Mat src = imread(file, 1);
Mat dst;
if (is_bw)
fastNlMeansDenoising(src, dst, h, template_size, search_size);
else
fastNlMeansDenoisingColored(src, dst, h, hColor, template_size, search_size);
imwrite(output, dst);
return 0;
}
|