SourceXtractorPlusPlus  0.10
Please provide a description of the project.
MeasurementFrameTaskFactory.cpp
Go to the documentation of this file.
1 
17 /*
18  * MeasurementFrameTaskFactory.cpp
19  *
20  * Created on: Nov 3, 2016
21  * Author: mschefer
22  */
23 
24 #include <iostream>
25 #include <sstream>
26 
28 #include <boost/filesystem.hpp>
29 
37 
38 namespace SourceXtractor {
39 
41  if (property_id.getTypeId() == PropertyId::create<MeasurementFrame>().getTypeId()) {
42  auto instance = property_id.getIndex();
43 
44  try {
45  return std::make_shared<MeasurementFrameTask>(instance, m_measurement_frames.at(instance));
46  } catch (const std::out_of_range&) {}
47  }
48  return nullptr;
49 }
50 
54 }
55 
57  const auto& image_infos = manager.getConfiguration<MeasurementImageConfig>().getImageInfos();
58 
59  BackgroundAnalyzerFactory background_analyzer_factory;
60  background_analyzer_factory.configure(manager);
61  for (auto& image_info : image_infos) {
62  auto measurement_frame = std::make_shared<MeasurementImageFrame>(
63  image_info.m_measurement_image,
64  image_info.m_weight_image,
65  image_info.m_weight_threshold,
66  image_info.m_coordinate_system,
67  image_info.m_gain,
68  image_info.m_saturation_level,
69  false);
70 
71  auto background_analyzer = background_analyzer_factory.createBackgroundAnalyzer(image_info.m_weight_type);
72  auto background_model = background_analyzer->analyzeBackground(
73  image_info.m_measurement_image,
74  image_info.m_weight_image,
75  ConstantImage<unsigned char>::create(image_info.m_measurement_image->getWidth(),
76  image_info.m_measurement_image->getHeight(), false),
77  measurement_frame->getVarianceThreshold());
78 
79  if (image_info.m_is_background_constant) {
80  measurement_frame->setBackgroundLevel(image_info.m_constant_background_value);
81  } else {
82  measurement_frame->setBackgroundLevel(background_model.getLevelMap());
83  }
84 
85  std::stringstream label;
86  label << boost::filesystem::basename(image_info.m_path) << "_" << image_info.m_image_hdu;
87  measurement_frame->setLabel(label.str());
88 
89  if (image_info.m_weight_image != nullptr) {
90  if (image_info.m_absolute_weight) {
91  measurement_frame->setVarianceMap(image_info.m_weight_image);
92  } else {
93  auto scaled_image = MultiplyImage<SeFloat>::create(
94  image_info.m_weight_image,
95  background_model.getScalingFactor());
96  measurement_frame->setVarianceMap(scaled_image);
97  }
98  } else {
99  measurement_frame->setVarianceMap(background_model.getVarianceMap());
100  }
101 
102  m_measurement_frames[image_info.m_id] = measurement_frame;
103  }
104 }
105 
106 }
STL class.
unsigned int getIndex() const
Definition: PropertyId.h:70
void reportConfigDependencies(Euclid::Configuration::ConfigManager &manager) const override
Registers all the Configuration dependencies.
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.
std::shared_ptr< BackgroundAnalyzer > createBackgroundAnalyzer() const
T str(T... args)
Identifier used to set and retrieve properties.
Definition: PropertyId.h:40
virtual std::shared_ptr< Task > createTask(const PropertyId &property_id) const override
Returns a Task producing a Property corresponding to the given PropertyId.
std::type_index getTypeId() const
Definition: PropertyId.h:66
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)
void configure(Euclid::Configuration::ConfigManager &manager) override
Method which should initialize the object.