SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
MeasurementFrameConfig.cpp
Go to the documentation of this file.
1
17
18#include <boost/filesystem.hpp>
19
22
26
28
29using namespace Euclid::Configuration;
30
31namespace SourceXtractor {
32
37
39 const auto& image_infos = getDependency<MeasurementImageConfig>().getImageInfos();
40 const auto& background_analyzer_factory = getDependency<BackgroundAnalyzerFactory>();
41
42 for (auto& image_info : image_infos) {
43 auto measurement_frame = std::make_shared<MeasurementImageFrame>(
44 image_info.m_measurement_image,
45 image_info.m_weight_image,
46 image_info.m_weight_threshold,
47 image_info.m_coordinate_system,
48 image_info.m_gain,
49 image_info.m_saturation_level,
50 false);
51
52 auto background_analyzer = background_analyzer_factory.createBackgroundAnalyzer(image_info.m_weight_type);
53 auto background_model = background_analyzer->analyzeBackground(
54 image_info.m_measurement_image,
55 image_info.m_weight_image,
56 ConstantImage<unsigned char>::create(image_info.m_measurement_image->getWidth(),
57 image_info.m_measurement_image->getHeight(), false),
58 measurement_frame->getVarianceThreshold());
59
60 if (image_info.m_is_background_constant) {
61 measurement_frame->setBackgroundLevel(image_info.m_constant_background_value);
62 } else {
63 measurement_frame->setBackgroundLevel(background_model.getLevelMap(), background_model.getMedianRms());
64 }
65
67 label << boost::filesystem::path(image_info.m_path).stem().string() << "_" << image_info.m_image_hdu;
68 measurement_frame->setLabel(label.str());
69
70 if (image_info.m_weight_image != nullptr) {
71 if (image_info.m_absolute_weight) {
72 measurement_frame->setVarianceMap(image_info.m_weight_image);
73 } else {
74 auto scaled_image = MultiplyImage<SeFloat>::create(
75 image_info.m_weight_image,
76 background_model.getScalingFactor());
77 measurement_frame->setVarianceMap(scaled_image);
78 if (image_info.m_weight_threshold < std::numeric_limits<WeightImage::PixelType>::max())
79 measurement_frame->setVarianceThreshold(image_info.m_weight_threshold*background_model.getScalingFactor());
80 }
81 } else {
82 measurement_frame->setVarianceMap(background_model.getVarianceMap());
83 }
84
85 m_measurement_frames[image_info.m_id] = measurement_frame;
86
87 CheckImages::getInstance().addMeasurementBackgroundCheckImage(image_info.m_id, measurement_frame->getBackgroundLevelMap());
89 }
90
91}
92
93}
94
std::map< std::string, boost::program_options::variable_value > UserValues
void addMeasurementBackgroundCheckImage(size_t index, std::shared_ptr< Image< SeFloat > > background_image)
static CheckImages & getInstance()
void addMeasurementVarianceCheckImage(size_t index, std::shared_ptr< Image< SeFloat > > variance_image)
static std::shared_ptr< ConstantImage< T > > create(int width, int height, T constant_value)
std::map< int, std::shared_ptr< MeasurementImageFrame > > m_measurement_frames
void initialize(const UserValues &args) override
static std::shared_ptr< ProcessedImage< T, MultiplyOperation< T > > > create(std::shared_ptr< const Image< T > > image_a, std::shared_ptr< const Image< T > > image_b)
T make_shared(T... args)
T max(T... args)
@ LayerVarianceMap
Definition Frame.h:45
T str(T... args)