summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Simianer <p@simianer.de>2017-04-01 21:43:28 +0200
committerPatrick Simianer <p@simianer.de>2017-04-01 21:43:28 +0200
commit139a731d10bf400c904b97cdd0654cc05881321d (patch)
tree268bb0a2efa33743c799d533b915ff7b04381b94
parentbd1d2ebbeea58cb376690b2a43177ecb9434cf1b (diff)
denoise
-rw-r--r--.gitignore1
-rw-r--r--denoise.cc47
2 files changed, 48 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index ee6d25a..dd5a379 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
crop
+denoise
merge
straighten
test/
diff --git a/denoise.cc b/denoise.cc
new file mode 100644
index 0000000..22f0792
--- /dev/null
+++ b/denoise.cc
@@ -0,0 +1,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;
+}
+