24#include <boost/algorithm/string.hpp>
25#include <boost/timer/timer.hpp>
45namespace po = boost::program_options;
46namespace timer = boost::timer;
79 auto i = args.
find(var);
83 auto basename = input.leaf();
84 while (!basename.extension().empty())
85 basename = basename.stem();
87 auto output_area = boost::filesystem::path(args.
at(
"output-area").as<
std::string>());
88 auto output = output_area / boost::filesystem::path(basename.native() +
"_" + algo +
"_" + default_suffix);
89 output.replace_extension(
"fits");
90 return output.native();
97 return Euclid::make_unique<SimpleBackgroundAnalyzer>();
110 po::options_description options;
116 options.add(config_manager.closeRegistration());
117 options.add_options()
118 (
"output", po::value<std::string>(),
"Output image for the background")
119 (
"output-variance", po::value<std::string>(),
"Output image for the variance")
120 (
"output-area", po::value<std::string>()->default_value(boost::filesystem::temp_directory_path().native()),
"Output area")
121 (
"algorithm", po::value<std::string>()->required(),
"Algorithm to use: Simple, ng")
122 (
"cell-size", po::value<std::string>()->default_value(
"64"),
"Cell size for the histogram")
123 (
"smooth-size", po::value<std::string>()->default_value(
"3"),
"Box size for the median filtering")
124 (
"no-write", po::bool_switch(),
"Do not write the image (skip interpolation)")
125 (
"tile-size", po::value<int>()->default_value(512),
"Tile size")
126 (
"tile-memory", po::value<int>()->default_value(2048),
"Tile memory limit");
133 config_manager.initialize(args);
142 boost::to_lower(algorithm_str);
151 auto tile_size = args.
at(
"tile-size").as<
int>();
152 auto tile_memory = args.
at(
"tile-memory").as<
int>();
164 assert (bg_analyzer !=
nullptr);
174 logger.
info() <<
"Weight image " << weight_image->getRepr();
178 timer::cpu_timer timer;
179 auto bg_model = bg_analyzer->analyzeBackground(image, weight_image, mask, threshold);
181 if (!args.
at(
"no-write").as<
bool>()) {
195 return Elements::ExitCode::OK;
static Elements::Logging logger
static long config_manager_id
DetectionImageConfig m_detection_config
std::string getOutputPath(const std::map< std::string, po::variable_value > &args, const std::string &var, const std::string &default_suffix)
WeightImageConfig m_weight_config
std::vector< int > m_cell_size
enum BenchBackgroundModel::Algorithm m_algorithm
Elements::ExitCode mainMethod(std::map< std::string, po::variable_value > &args) override
po::options_description defineSpecificProgramOptions() override
std::unique_ptr< BackgroundAnalyzer > getBackgroundAnalyzer()
void configure(const std::map< std::string, po::variable_value > &args)
std::vector< int > m_smooth
std::map< std::string, Algorithm > s_algo_map
static Logging getLogger(const std::string &name="")
void info(const std::string &logMessage)
static ConfigManager & getInstance(long id)
#define MAIN_FOR(ELEMENTS_PROGRAM_NAME)
long getUniqueManagerId() noexcept