SourceXtractorPlusPlus  0.13
Please provide a description of the project.
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 
30 using namespace Euclid::Configuration;
31 namespace po = boost::program_options;
32 
33 namespace SourceXtractor {
34 
35 static const std::string MTHRESH_USE {"partition-multithreshold"};
36 static const std::string MTHRESH_THRESHOLDS_NB {"partition-threshold-count"};
37 static const std::string MTHRESH_MIN_AREA {"partition-minimum-area"};
38 static const std::string MTHRESH_MIN_CONTRAST {"partition-minimum-contrast"};
39 
40 MultiThresholdPartitionConfig::MultiThresholdPartitionConfig(long manager_id) : Configuration(manager_id) {
41  declareDependency<PartitionStepConfig>();
42 
44 }
45 
47  return { {"Multi-thresholding", {
48  {MTHRESH_USE.c_str(), po::bool_switch(), "activates 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) {
70  return std::make_shared<MultiThresholdPartitionStep>(source_factory, min_contrast, threshold_nb, min_area);
71  }
72  );
73  }
74 }
75 
76 } // SourceXtractor namespace
SourceXtractor::MultiThresholdPartitionConfig::initialize
void initialize(const UserValues &args) override
Definition: MultiThresholdPartitionConfig.cpp:55
std::string
STL class.
SourceXtractor::MinAreaPartitionConfig
Definition: MinAreaPartitionConfig.h:29
std::shared_ptr< SourceFactory >
SourceXtractor::MultiThresholdPartitionConfig::getProgramOptions
std::map< std::string, OptionDescriptionList > getProgramOptions() override
Definition: MultiThresholdPartitionConfig.cpp:46
Euclid::Configuration
MultiThresholdPartitionStep.h
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::MTHRESH_USE
static const std::string MTHRESH_USE
Definition: MultiThresholdPartitionConfig.cpp:35
std::map::at
T at(T... args)
std::string::c_str
T c_str(T... args)
SourceXtractor::MultiThresholdPartitionConfig::MultiThresholdPartitionConfig
MultiThresholdPartitionConfig(long manager_id)
Definition: MultiThresholdPartitionConfig.cpp:40
MultiThresholdPartitionConfig.h
Elements::Exception
std::map
STL class.
PartitionStepConfig.h
Euclid::Configuration::Configuration
SourceXtractor::MTHRESH_THRESHOLDS_NB
static const std::string MTHRESH_THRESHOLDS_NB
Definition: MultiThresholdPartitionConfig.cpp:36
SourceXtractor::MTHRESH_MIN_CONTRAST
static const std::string MTHRESH_MIN_CONTRAST
Definition: MultiThresholdPartitionConfig.cpp:38
SourceXtractor::MTHRESH_MIN_AREA
static const std::string MTHRESH_MIN_AREA
Definition: MultiThresholdPartitionConfig.cpp:37
Euclid::Configuration::ConfigManager::getInstance
static ConfigManager & getInstance(long id)
Euclid::Configuration::ConfigManager::registerDependency
void registerDependency()
MinAreaPartitionConfig.h