SourceXtractorPlusPlus 1.0.3
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
29
31
32using namespace Euclid::Configuration;
33namespace po = boost::program_options;
34
35namespace SourceXtractor {
36
37static const std::string MTHRESH_USE {"partition-multithreshold"};
38static const std::string MTHRESH_THRESHOLDS_NB {"partition-threshold-count"};
39static const std::string MTHRESH_MIN_AREA {"partition-minimum-area"};
40static const std::string MTHRESH_MIN_CONTRAST {"partition-minimum-contrast"};
41
50
52 return { {"Multi-thresholding", {
53 {MTHRESH_USE.c_str(), po::value<bool>()->default_value(true), "activates/deactivates multithreshold partitioning"},
54 {MTHRESH_THRESHOLDS_NB.c_str(), po::value<int>()->default_value(32), "# of thresholds"},
55 {MTHRESH_MIN_AREA.c_str(), po::value<int>()->default_value(3), "min area in pixels to consider partitioning"},
56 {MTHRESH_MIN_CONTRAST.c_str(), po::value<double>()->default_value(0.005), "min contrast of for partitioning"}
57 }}};
58}
59
61 // We can only use this if we have a detection image and it was on by default
62 if (getDependency<DetectionFrameConfig>().getDetectionFrames().size() > 0) {
63 if (args.at(MTHRESH_USE).as<bool>()) {
64 auto threshold_nb = args.at(MTHRESH_THRESHOLDS_NB).as<int>();
65 auto min_area = args.at(MTHRESH_MIN_AREA).as<int>();
66 auto min_contrast = args.at(MTHRESH_MIN_CONTRAST).as<double>();
67 auto seed = getDependency<RngConfig>().getSeed();
68
69 if (min_area <= 0) {
70 throw Elements::Exception() << "Invalid " << MTHRESH_MIN_AREA << " value: " << min_area;
71 }
72 if (threshold_nb <= 0) {
73 throw Elements::Exception() << "Invalid " << MTHRESH_THRESHOLDS_NB << " value: " << threshold_nb;
74 }
75
76 getDependency<PartitionStepConfig>().addPartitionStepCreator(
77 [=](std::shared_ptr<SourceFactory> source_factory) {
79 source_factory, min_contrast, threshold_nb, min_area, seed);
80 });
81 }
82 }
83}
84
85} // SourceXtractor namespace
T at(T... args)
static ConfigManager & getInstance(long id)
std::map< std::string, boost::program_options::variable_value > UserValues
std::map< std::string, OptionDescriptionList > getProgramOptions() override
T make_shared(T... args)
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