diff options
author | Patrick Simianer <p@simianer.de> | 2017-04-01 21:44:04 +0200 |
---|---|---|
committer | Patrick Simianer <p@simianer.de> | 2017-04-01 21:44:04 +0200 |
commit | 13fd4101f993e22bc0b51ae9237ee782173f9415 (patch) | |
tree | be771d54851998cdaa7775c81f46057bbe05c0bd | |
parent | 139a731d10bf400c904b97cdd0654cc05881321d (diff) |
unsharp-mask
-rw-r--r-- | unsharp-mask.cc | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/unsharp-mask.cc b/unsharp-mask.cc new file mode 100644 index 0000000..f5cbeb1 --- /dev/null +++ b/unsharp-mask.cc @@ -0,0 +1,37 @@ +#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>()) + ("s,sigma", "sigma for Gaussian Blur", cxxopts::value<float>()->default_value("3.0")) + ("a,alpha", "weight of the first array elements", cxxopts::value<float>()->default_value("1.5")) + ("b,beta", "weight of the second array elements", cxxopts::value<float>()->default_value("-0.5")) + ("g,gamma", "scalar added to each sum", cxxopts::value<float>()->default_value("0")) + ("o,output", "output file", cxxopts::value<string>()); + + opt.parse(argc, argv); + + auto& file = opt["f"].as<string>(); + auto& output = opt["o"].as<string>(); + float sigma = opt["s"].as<float>(); + float alpha = opt["a"].as<float>(); + float beta = opt["b"].as<float>(); + + Mat src = imread(file, 1), dst; + cv::GaussianBlur(src, dst, cv::Size(0, 0), sigma); + cv::addWeighted(src, alpha, dst, beta, 0, dst); + imwrite(output, dst); + + return 0; +} + |