SourceXtractorPlusPlus  0.12
Please provide a description of the project.
MeasurementFrameConfig.cpp
Go to the documentation of this file.
1 
18 #include <boost/filesystem.hpp>
19 
22 
25 
27 
28 using namespace Euclid::Configuration;
29 
30 namespace SourceXtractor {
31 
32 MeasurementFrameConfig::MeasurementFrameConfig(long manager_id) : Configuration(manager_id) {
33  declareDependency<MeasurementImageConfig>();
34  declareDependency<BackgroundAnalyzerFactory>();
35 }
36 
38  const auto& image_infos = getDependency<MeasurementImageConfig>().getImageInfos();
39  const auto& background_analyzer_factory = getDependency<BackgroundAnalyzerFactory>();
40 
41  for (auto& image_info : image_infos) {
42  auto measurement_frame = std::make_shared<MeasurementImageFrame>(
43  image_info.m_measurement_image,
44  image_info.m_weight_image,
45  image_info.m_weight_threshold,
46  image_info.m_coordinate_system,
47  image_info.m_gain,
48  image_info.m_saturation_level,
49  false);
50 
51  auto background_analyzer = background_analyzer_factory.createBackgroundAnalyzer(image_info.m_weight_type);
52  auto background_model = background_analyzer->analyzeBackground(
53  image_info.m_measurement_image,
54  image_info.m_weight_image,
55  ConstantImage<unsigned char>::create(image_info.m_measurement_image->getWidth(),
56  image_info.m_measurement_image->getHeight(), false),
57  measurement_frame->getVarianceThreshold());
58 
59  if (image_info.m_is_background_constant) {
60  measurement_frame->setBackgroundLevel(image_info.m_constant_background_value);
61  } else {
62  measurement_frame->setBackgroundLevel(background_model.getLevelMap(), background_model.getMedianRms());
63  }
64 
65  std::stringstream label;
66  label << boost::filesystem::basename(image_info.m_path) << "_" << image_info.m_image_hdu;
67  measurement_frame->setLabel(label.str());
68 
69  if (image_info.m_weight_image != nullptr) {
70  if (image_info.m_absolute_weight) {
71  measurement_frame->setVarianceMap(image_info.m_weight_image);
72  } else {
73  auto scaled_image = MultiplyImage<SeFloat>::create(
74  image_info.m_weight_image,
75  background_model.getScalingFactor());
76  measurement_frame->setVarianceMap(scaled_image);
77  }
78  } else {
79  measurement_frame->setVarianceMap(background_model.getVarianceMap());
80  }
81 
82  m_measurement_frames[image_info.m_id] = measurement_frame;
83  }
84 
85 }
86 
87 }
88 
STL class.
T str(T... args)
void initialize(const UserValues &args) override
std::map< int, std::shared_ptr< MeasurementImageFrame > > m_measurement_frames
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T >> image_a, std::shared_ptr< const Image< T >> image_b)