SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
MultiThresholdPartitionConfig.cpp
Go to the documentation of this file.
1
17/*
18 * MultiThresholdPartitionConfig.cpp
19 *
20 * Created on: Jan 18, 2017
21 * Author: mschefer
22 */
23
27
29
30using namespace Euclid::Configuration;
31namespace po = boost::program_options;
32
33namespace SourceXtractor {
34
35static const std::string MTHRESH_USE {"partition-multithreshold"};
36static const std::string MTHRESH_THRESHOLDS_NB {"partition-threshold-count"};
37static const std::string MTHRESH_MIN_AREA {"partition-minimum-area"};
38static const std::string MTHRESH_MIN_CONTRAST {"partition-minimum-contrast"};
39
45
47 return { {"Multi-thresholding", {
48 {MTHRESH_USE.c_str(), po::value<bool>()->default_value(true), "activates/deactivates multithreshold partitioning"},
49 {MTHRESH_THRESHOLDS_NB.c_str(), po::value<int>()->default_value(32), "# of thresholds"},
50 {MTHRESH_MIN_AREA.c_str(), po::value<int>()->default_value(3), "min area in pixels to consider partitioning"},
51 {MTHRESH_MIN_CONTRAST.c_str(), po::value<double>()->default_value(0.005), "min contrast of for partitioning"}
52 }}};
53}
54
56 if (args.at(MTHRESH_USE).as<bool>()) {
57 auto threshold_nb = args.at(MTHRESH_THRESHOLDS_NB).as<int>();
58 auto min_area = args.at(MTHRESH_MIN_AREA).as<int>();
59 auto min_contrast = args.at(MTHRESH_MIN_CONTRAST).as<double>();
60
61 if (min_area <= 0) {
62 throw Elements::Exception() << "Invalid " << MTHRESH_MIN_AREA << " value: " << min_area;
63 }
64 if (threshold_nb <= 0) {
65 throw Elements::Exception() << "Invalid " << MTHRESH_THRESHOLDS_NB << " value: " << threshold_nb;
66 }
67
68 getDependency<PartitionStepConfig>().addPartitionStepCreator(
69 [=](std::shared_ptr<SourceFactory> source_factory) {
71 }
72 );
73 }
74}
75
76} // SourceXtractor namespace
static ConfigManager & getInstance(long id)
std::map< std::string, OptionDescriptionList > getProgramOptions() override
static const std::string MTHRESH_THRESHOLDS_NB
static const std::string MTHRESH_MIN_AREA
static const std::string MTHRESH_MIN_CONTRAST
static const std::string MTHRESH_USE