SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
DetectionFrameConfig.cpp
Go to the documentation of this file.
1
17
18#include <iostream>
19
20#include <boost/filesystem.hpp>
21
22#include "Configuration/ConfigManager.h"
23
26
31
33
35
36using namespace Euclid::Configuration;
37namespace po = boost::program_options;
38
39namespace SourceXtractor {
40
47
49
50 for (size_t i=0; i<getDependency<DetectionImageConfig>().getExtensionsNb(); i++) {
51 auto detection_image = getDependency<DetectionImageConfig>().getDetectionImage(i);
52 auto detection_image_path = getDependency<DetectionImageConfig>().getDetectionImagePath();
53 auto detection_image_coordinate_system = getDependency<DetectionImageConfig>().getCoordinateSystem(i);
54 auto detection_image_gain = getDependency<DetectionImageConfig>().getGain(i);
55 auto detection_image_saturation = getDependency<DetectionImageConfig>().getSaturation(i);
56 auto interpolation_gap = getDependency<DetectionImageConfig>().getInterpolationGap(i);
57
58 auto weight_image = getDependency<WeightImageConfig>().getWeightImage(i);
59 auto weight_threshold = getDependency<WeightImageConfig>().getWeightThreshold(i);
60 bool is_weight_absolute = getDependency<WeightImageConfig>().isWeightAbsolute();
61
62 auto detection_frame = std::make_shared<DetectionImageFrame>(detection_image, weight_image,
63 weight_threshold, detection_image_coordinate_system, detection_image_gain,
64 detection_image_saturation, interpolation_gap);
65 detection_frame->setLabel(boost::filesystem::path(detection_image_path).stem().string());
66
67 auto background_analyzer = getDependency<BackgroundAnalyzerFactory>().createBackgroundAnalyzer();
68 auto background_model = background_analyzer->analyzeBackground(detection_frame->getOriginalImage(), weight_image,
69 ConstantImage<unsigned char>::create(detection_image->getWidth(), detection_image->getHeight(), false), detection_frame->getVarianceThreshold());
70
71 detection_frame->setBackgroundLevel(background_model.getLevelMap(), background_model.getMedianRms());
72
73 if (weight_image != nullptr) {
74 if (is_weight_absolute) {
75 detection_frame->setVarianceMap(weight_image);
76 } else {
77 // apply the rms scaling factor from the background
78 auto bck_scaling_factor = background_model.getScalingFactor();
79 auto scaled_image = MultiplyImage<SeFloat>::create(weight_image, bck_scaling_factor);
80 detection_frame->setVarianceMap(scaled_image);
81 detection_frame->setVarianceThreshold(detection_frame->getVarianceThreshold()*bck_scaling_factor);
82 }
83 } else {
84 // re-set the variance check image to what's in the detection_frame()
85 detection_frame->setVarianceMap(background_model.getVarianceMap());
86 }
87
88 const auto& background_config = getDependency<BackgroundConfig>();
89 // Override background level and threshold if requested by the user
90 if (background_config.isBackgroundLevelAbsolute()) {
92 detection_image->getWidth(), detection_image->getHeight(), background_config.getBackgroundLevel());
93
94 detection_frame->setBackgroundLevel(background, background_model.getMedianRms());
95
97 } else {
98 CheckImages::getInstance().addBackgroundCheckImage(background_model.getLevelMap());
99 }
100
101 if (background_config.isDetectionThresholdAbsolute()) {
102 detection_frame->setDetectionThreshold(background_config.getDetectionThreshold());
103 }
104
105 auto img_source = getDependency<DetectionImageConfig>().getImageSource(i);
106 detection_frame->setMetadata(img_source->getMetadata());
107
108 detection_frame->setHduIndex(i);
109
111
112 m_frames.emplace_back(detection_frame);
113 }
114}
115
116}
std::map< std::string, boost::program_options::variable_value > UserValues
void addVarianceCheckImage(std::shared_ptr< Image< SeFloat > > variance_image)
static CheckImages & getInstance()
void addBackgroundCheckImage(std::shared_ptr< Image< SeFloat > > background_image)
static std::shared_ptr< ConstantImage< T > > create(int width, int height, T constant_value)
std::vector< std::shared_ptr< DetectionImageFrame > > m_frames
void initialize(const UserValues &args) override
DetectionFrameConfig(long manager_id)
Constructs a new DetectionFrameConfig object.
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)
@ LayerVarianceMap
Definition Frame.h:45