SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
Cleaning.cpp
Go to the documentation of this file.
1
17/*
18 * Cleaning.cpp
19 *
20 * Created on: 2018 M12 18
21 * Author: mschefer
22 */
23
24#include <vector>
25#include <set>
26#include <tuple>
27
31
34
36
38
39namespace SourceXtractor {
40
42 return &(*a) < &(*b);
43}
44
46 if (group.size() <= 1) {
47 return;
48 }
49
52
53 // iterate through all sources
54 for (auto it = group.begin(); it != group.end(); ++it) {
55 if (shouldClean(*it, group)) {
56 sources_to_clean.push_back(it);
57 } else {
58 remaining_sources.push_back(it);
59 }
60 }
61
62 if (sources_to_clean.size() > 0) {
63 if (remaining_sources.size() > 1) {
65 for (auto it : sources_to_clean) {
68 }
69
70 for (auto merging_pair : merging_map) {
71 if (merging_pair.second.size() > 0) {
72 auto new_source = mergeSources(*merging_pair.first, merging_pair.second);
73 group.addSource(std::move(new_source));
74 group.removeSource(merging_pair.first);
75 }
76 }
77 } else if (remaining_sources.size() == 1) {
79 group.addSource(std::move(new_source));
80 group.removeSource(remaining_sources[0]);
81 }
82
83 for (auto& it : sources_to_clean) {
84 group.removeSource(it);
85 }
86 }
87}
88
90 const auto& pixel_list = source.getProperty<PixelCoordinateList>().getCoordinateList();
91
92 std::vector<double> group_influence(pixel_list.size());
93
94 // iterate through all other sources in the group
95 for (auto it = group.begin(); it != group.end(); ++it) {
96 if (&(*it) == &source) { // skip self
97 continue;
98 }
99
100 auto &model = it->getProperty<MoffatModelEvaluator>();
101 int i = 0;
102 for (auto pixel : pixel_list) {
103 auto pixel_value = model.getValue(pixel.m_x, pixel.m_y);
105 }
106 }
107
108 unsigned int still_valid_pixels = 0;
109 const auto& pixel_values = source.getProperty<DetectionFramePixelValues>().getFilteredValues();
110 int i = 0;
111 for (auto value : pixel_values) {
112 if (value > group_influence[i++]) {
114 }
115 }
116
118}
119
122
123 const auto& pixel_list = source.getProperty<PixelCoordinateList>().getCoordinateList();
124
126
127 // iterate through all other sources in the group
128 for (size_t i = 0; i < candidates.size(); i++) {
129 auto &model = candidates[i]->getProperty<MoffatModelEvaluator>();
130 for (auto pixel : pixel_list) {
131 auto pixel_value = model.getValue(pixel.m_x, pixel.m_y);
133 }
134 }
135
138 for (size_t i = 0; i < candidates.size(); i++) {
142 }
143 }
145}
146
149
150 // Start with a copy of the pixel list of the parent
151 auto pixel_list = parent.getProperty<PixelCoordinateList>().getCoordinateList();
152
153 // Merge the pixel lists of all the child sources
154 for (const auto& child : children) {
155 const auto& pixel_list_to_merge = child->getProperty<PixelCoordinateList>().getCoordinateList();
156 pixel_list.insert(pixel_list.end(), pixel_list_to_merge.begin(), pixel_list_to_merge.end());
157 }
158
159 // Create a new source with the minimum necessary properties
160 auto new_source = m_source_factory->createSource();
161 new_source->setProperty<PixelCoordinateList>(pixel_list);
162 new_source->setProperty<DetectionFrame>(parent.getProperty<DetectionFrame>().getEncapsulatedFrame());
163 new_source->setProperty<SourceId>(parent.getProperty<SourceId>().getSourceId());
164
165 return new_source;
166}
167
169 return {
170 PropertyId::create<PixelCoordinateList>(),
171 PropertyId::create<MoffatModelEvaluator>()
172 };
173}
174
175}
176
std::unique_ptr< SourceInterface > mergeSources(SourceInterface &parent, const std::vector< SourceGroupInterface::iterator > children) const
Definition Cleaning.cpp:147
SourceGroupInterface::iterator findMostInfluentialSource(SourceInterface &source, const std::vector< SourceGroupInterface::iterator > &candidates) const
Definition Cleaning.cpp:120
unsigned int m_min_area
Definition Cleaning.h:57
void deblend(SourceGroupInterface &group) const override
Performs the DeblendStep on the SourceGroup.
Definition Cleaning.cpp:45
std::shared_ptr< SourceFactory > m_source_factory
Definition Cleaning.h:56
std::set< PropertyId > requiredProperties() const override
Returns properties used by the deblend step.
Definition Cleaning.cpp:168
bool shouldClean(SourceInterface &source, SourceGroupInterface &group) const
Definition Cleaning.cpp:89
The values of a Source's pixels in the detection image. They are returned as a vector in the same ord...
Defines the interface used to group sources.
std::list< SourceWrapper >::iterator iterator
The SourceInterface is an abstract "source" that has properties attached to it.
T move(T... args)
bool operator<(std::reference_wrapper< const SourceInterface > a, std::reference_wrapper< const SourceInterface > b)