SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
ShapeParametersTask.cpp
Go to the documentation of this file.
1
17/*
18 * ShapeParametersTask.cpp
19 *
20 * Created on: Jan 27, 2017
21 * Author: mschefer
22 */
23
24#include <iostream>
25
31
33
34namespace SourceXtractor {
35
37 const auto& pixel_values = source.getProperty<DetectionFramePixelValues>().getFilteredValues();
38 const auto& centroid_x = source.getProperty<PixelCentroid>().getCentroidX();
39 const auto& centroid_y = source.getProperty<PixelCentroid>().getCentroidY();
40 auto min_value = source.getProperty<PeakValue>().getMinValue();
41 auto peak_value = source.getProperty<PeakValue>().getMaxValue();
42 auto& coordinates = source.getProperty<PixelCoordinateList>().getCoordinateList();
43
44 SeFloat x_2 = 0.0;
45 SeFloat y_2 = 0.0;
46 SeFloat x_y = 0.0;
47
49
52 int nb_of_pixels = coordinates.size();
53
54 auto i = pixel_values.begin();
55 for (auto pixel_coord : coordinates) {
56 SeFloat value = *i++;
59
60 if (value > half_peak_threshold) {
62 }
63
64 x_2 += x_pos * x_pos * value;
65 y_2 += y_pos * y_pos * value;
66 x_y += x_pos * y_pos * value;
67
68 total_intensity += value;
69 }
70
74
76 if (fabs(x_2 - y_2) > 0.0) {
77 theta = atan2(2.0 * x_y, x_2 - y_2) / 2.0;
78 } else {
79 theta = M_PI/4.0;
80 }
81
82 float temp = x_2 - y_2;
83 temp = sqrt(0.25 * temp * temp + x_y * x_y);
84 SeFloat a = sqrt((x_2 + y_2) / 2 + temp);
85 SeFloat b = ((x_2 + y_2) / 2) > temp ? sqrt((x_2 + y_2) / 2 - temp) : 0;
86
87 // From original SExtractor: Handle fully correlated x/y (which cause a singularity...)
88 SeFloat tmp = x_2 * y_2 - x_y * x_y;
89 bool singu=false;
90 if (tmp < 0.00694) {
91 x_2 += 0.0833333;
92 y_2 += 0.0833333;
93 tmp = x_2 * y_2 - x_y * x_y;
94 singu=true;
95 }
96
97 SeFloat cxx = y_2 / tmp;
98 SeFloat cyy = x_2 / tmp;
99 SeFloat cxy = -2.0 * x_y / tmp;
100
103
104 SeFloat abcor = 1.0;
105 if (t1t2 > 0.0) { // && !prefs.dweight_flag
106 abcor = (area_under_half > 0.0 ? area_under_half : 1.0) / (2 * M_PI * -log(t1t2 < 1.0 ? t1t2 : 0.99) * a * b);
107 if (abcor > 1.0) {
108 abcor = 1.0;
109 }
110 }
111
112 // set the object property
114}
115
116
117}
T atan2(T... args)
The values of a Source's pixels in the detection image. They are returned as a vector in the same ord...
The centroid of all the pixels in the source, weighted by their DetectionImage pixel values.
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
The SourceInterface is an abstract "source" that has properties attached to it.
T fabs(T... args)
T log(T... args)
T sqrt(T... args)