25 #include <boost/algorithm/string.hpp>
38 using namespace Euclid::Configuration;
39 namespace po = boost::program_options;
41 namespace SourceXtractor {
50 WeightImageConfig::WeightImageConfig(
long manager_id) :
52 m_weight_type(
WeightType::WEIGHT_TYPE_FROM_BACKGROUND),
53 m_absolute_weight(false),
55 m_weight_threshold(0),
56 m_symmetry_usage(true) {
58 declareDependency<DetectionImageConfig>();
62 return { {
"Weight image", {
64 "Path to a fits format image to be used as weight image."},
66 "Is the weight map provided as absolute values or relative to background."},
68 "Weight image type [none|background|rms|variance|weight]."},
70 "Weight map scaling factor."},
72 "Threshold for pixels to be considered bad pixels. In same units as weight map."},
74 "Use object symmetry to replace pixels above the weight threshold for photometry."},
81 switch (weight_type) {
85 return threshold * threshold;
90 return 1.0 / threshold;
108 if (weight_image_filename !=
"") {
113 auto weight_iter = WEIGHT_MAP.find(weight_type_name);
114 if (weight_iter == WEIGHT_MAP.end()) {
123 auto flux_scale = getDependency<DetectionImageConfig>().getOriginalFluxScale();
138 throw Elements::Exception() <<
"Please give an appropriate weight type for image: " << weight_image_filename;
140 throw Elements::Exception() <<
"Please give an appropriate weight type for image: " << weight_image_filename;
142 throw Elements::Exception() <<
"Setting absolute weight but providing *no* weight image does not make sense.";
154 return "WeightMapImageSource(" + getImageRepr() +
")";
162 generateFromRms(tile,
width,
height, *image_chunk);
165 generateFromVariance(tile,
width,
height, *image_chunk);
168 generateFromWeight(tile,
width,
height, *image_chunk);
179 for (
int iy = 0; iy <
height; iy++) {
180 for (
int ix = 0; ix <
width; ix++) {
181 auto value = image_chunk.
getValue(ix, iy) * m_scaling;
194 for (
int iy = 0; iy <
height; iy++) {
195 for (
int ix = 0; ix <
width; ix++) {
196 auto value = image_chunk.
getValue(ix, iy) * m_scaling;
204 for (
int iy = 0; iy <
height; iy++) {
205 for (
int ix = 0; ix <
width; ix++) {
206 auto value = image_chunk.
getValue(ix, iy) * m_scaling;
230 std::make_shared<WeightMapImageSource>(weight_image, weight_type, scaling));
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y