SourceXtractorPlusPlus 0.19.2
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
MeasurementFrameConfig.cpp
Go to the documentation of this file.
1
18#include <boost/filesystem.hpp>
19
22
25
27
28using namespace Euclid::Configuration;
29
30namespace SourceXtractor {
31
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
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 if (image_info.m_weight_threshold < std::numeric_limits<WeightImage::PixelType>::max())
78 measurement_frame->setVarianceThreshold(image_info.m_weight_threshold*background_model.getScalingFactor());
79 }
80 } else {
81 measurement_frame->setVarianceMap(background_model.getVarianceMap());
82 }
83
84 m_measurement_frames[image_info.m_id] = measurement_frame;
85 }
86
87}
88
89}
90
std::map< int, std::shared_ptr< MeasurementImageFrame > > m_measurement_frames
void initialize(const UserValues &args) override
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T > > image_a, std::shared_ptr< const Image< T > > image_b)
T str(T... args)