SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Configuration
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
24
#include "
SEFramework/Image/ConstantImage.h
"
25
#include "
SEFramework/Image/ProcessedImage.h
"
26
27
#include "
SEImplementation/Background/BackgroundAnalyzerFactory.h
"
28
#include "
SEImplementation/Configuration/BackgroundConfig.h
"
29
#include "
SEImplementation/Configuration/DetectionImageConfig.h
"
30
#include "
SEImplementation/Configuration/WeightImageConfig.h
"
31
32
#include "
SEImplementation/CheckImages/CheckImages.h
"
33
34
#include "
SEImplementation/Configuration/DetectionFrameConfig.h
"
35
36
using namespace
Euclid::Configuration
;
37
namespace
po = boost::program_options;
38
39
namespace
SourceXtractor
{
40
41
DetectionFrameConfig::DetectionFrameConfig
(
long
manager_id
) :
Configuration
(
manager_id
) {
42
declareDependency<WeightImageConfig>
();
43
declareDependency<DetectionImageConfig>
();
44
declareDependency<BackgroundConfig>
();
45
declareDependency<BackgroundAnalyzerFactory>
();
46
}
47
48
void
DetectionFrameConfig::initialize
(
const
UserValues
& ) {
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::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
) {
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()) {
91
auto
background
=
ConstantImage<DetectionImage::PixelType>::create
(
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
110
CheckImages::getInstance
().addVarianceCheckImage(
detection_frame
->getImage(
FrameImageLayer::LayerVarianceMap
));
111
CheckImages::getInstance
().addFilteredCheckImage(
detection_frame
->getImage(
FrameImageLayer::LayerFilteredImage
));
112
CheckImages::getInstance
().addThresholdedCheckImage(
detection_frame
->getImage(
FrameImageLayer::LayerThresholdedImage
));
113
CheckImages::getInstance
().addSnrCheckImage(
detection_frame
->getImage(
FrameImageLayer::LayerSignalToNoiseMap
));
114
115
m_frames
.emplace_back(
detection_frame
);
116
}
117
}
118
119
}
BackgroundAnalyzerFactory.h
BackgroundConfig.h
CheckImages.h
ConstantImage.h
DetectionFrameConfig.h
DetectionImageConfig.h
ProcessedImage.h
WeightImageConfig.h
Euclid::Configuration::Configuration
SourceXtractor::CheckImages::getInstance
static CheckImages & getInstance()
Definition
CheckImages.h:158
SourceXtractor::ConstantImage
Definition
ConstantImage.h:33
SourceXtractor::ConstantImage::create
static std::shared_ptr< ConstantImage< T > > create(int width, int height, T constant_value)
Definition
ConstantImage.h:42
SourceXtractor::DetectionFrameConfig::m_frames
std::vector< std::shared_ptr< DetectionImageFrame > > m_frames
Definition
DetectionFrameConfig.h:51
SourceXtractor::DetectionFrameConfig::initialize
void initialize(const UserValues &args) override
Definition
DetectionFrameConfig.cpp:48
SourceXtractor::DetectionFrameConfig::DetectionFrameConfig
DetectionFrameConfig(long manager_id)
Constructs a new DetectionFrameConfig object.
Definition
DetectionFrameConfig.cpp:41
std::function
std::map
Euclid::Configuration
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::LayerVarianceMap
@ LayerVarianceMap
Definition
Frame.h:45
SourceXtractor::LayerFilteredImage
@ LayerFilteredImage
Definition
Frame.h:40
SourceXtractor::LayerThresholdedImage
@ LayerThresholdedImage
Definition
Frame.h:41
SourceXtractor::LayerSignalToNoiseMap
@ LayerSignalToNoiseMap
Definition
Frame.h:42
Generated by
1.10.0