SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
DetectionFrameConfig.cpp
Go to the documentation of this file.
1
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();
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
65 detection_frame->setLabel(boost::filesystem::basename(detection_image_path));
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) {
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();
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
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
96 CheckImages::getInstance().addBackgroundCheckImage(background);
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
114
115 m_frames.emplace_back(detection_frame);
116 }
117}
118
119}
static CheckImages & getInstance()
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.
@ LayerVarianceMap
Definition Frame.h:45
@ LayerFilteredImage
Definition Frame.h:40
@ LayerThresholdedImage
Definition Frame.h:41
@ LayerSignalToNoiseMap
Definition Frame.h:42