32 namespace SourceXtractor {
39 auto bbox_min = bounds.getMin();
40 auto bbox_max = bounds.getMax();
42 auto value_function = [bbox_min, bbox_max, &stamp](
PixelCoordinate coord) {
43 if (coord.m_x < bbox_min.m_x || coord.m_x > bbox_max.m_x || coord.m_y < bbox_min.m_y || coord.m_y > bbox_max.m_y) {
46 auto offset_coord = coord - bbox_min;
47 return stamp.getValue(offset_coord.m_x, offset_coord.m_y);
52 pixel_coordinates.
reserve(pixel_list.size());
53 for (
auto& pixel : pixel_list) {
63 if (merged.size() == 1) {
67 for (
auto& source_pixels : merged) {
70 new_source->setProperty<
DetectionFrame>(detection_frame.getEncapsulatedFrame());
91 if (pixels_with_origin.size() == 0) {
97 for (
auto& pixel_origin : pixels_with_origin) {
98 auto pixel = pixel_origin.first;
99 auto origin = pixel_origin.second;
102 for (
int i=0; i<5; i++) {
103 values[i] = value_function(pixel + offsets[i]);
107 for (
int i=1; i<3; i++) {
108 if (values[i] > values[max]) {
112 for (
int i=3; i<5; i++) {
113 if (values[i] >= values[max]) {
120 attractors[pixel].push_back(origin);
126 attractPixels(pixels_to_be_processed, attractors, value_function);
135 for (
auto& attractor : attractors) {
136 auto coord = attractor.first;
137 auto& pixels = attractor.second;
140 for (
size_t i=0; i < merged.
size(); i++) {
141 if (coord.m_x >= bbox_min[i].m_x-1 && coord.m_x <= bbox_max[i].m_x+1 && coord.m_y >= bbox_min[i].m_y-1 && coord.m_y <= bbox_max[i].m_y+1) {
144 merged[i].
insert(merged[i].
begin(), pixels.begin(), pixels.end());