#include #include #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()) ("b,black_and_white", "image is black and white") ("h,hh", "h", cxxopts::value()->default_value("3.0")) ("C,hColor", "hColor", cxxopts::value()->default_value("3.0")) ("t,template_size", "template window size", cxxopts::value()->default_value("7")) ("s,search_size", "search window size", cxxopts::value()->default_value("21")) ("T,threads", "number of threads", cxxopts::value()->default_value("1")) ("o,output", "output file", cxxopts::value()); opt.parse(argc, argv); auto& file = opt["f"].as(); auto is_bw = opt.count("b"); auto& output = opt["o"].as(); float h = opt["h"].as(); float hColor = opt["C"].as(); float template_size = opt["t"].as(); float search_size = opt["s"].as(); setNumThreads(opt["T"].as()); 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; }