SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Plugin
ErrorEllipse
ErrorEllipseTask.cpp
Go to the documentation of this file.
1
17
/*
18
* ErrorEllipseTask.cpp
19
*
20
* Created on: Feb 11 2022
21
* Author: mkuemmel
22
*/
23
24
#include <iostream>
25
26
#include "
SEImplementation/Property/PixelCoordinateList.h
"
27
#include "
SEImplementation/Plugin/DetectionFramePixelValues/DetectionFramePixelValues.h
"
28
#include "
SEImplementation/Plugin/ErrorEllipse/ErrorEllipse.h
"
29
#include "
SEImplementation/Plugin/ShapeParameters/ShapeParameters.h
"
30
#include "
SEImplementation/Plugin/PixelCentroid/PixelCentroid.h
"
31
#include "
SEImplementation/Plugin/PeakValue/PeakValue.h
"
32
33
#include "
SEImplementation/Plugin/ErrorEllipse/ErrorEllipseTask.h
"
34
35
namespace
SourceXtractor
{
36
37
void
ErrorEllipseTask::computeProperties
(
SourceInterface
&
source
)
const
{
38
const
auto
&
pixel_variances
=
source
.getProperty<
DetectionFramePixelValues
>().getVariances();
39
const
auto
&
centroid_x
=
source
.getProperty<
PixelCentroid
>().getCentroidX();
40
const
auto
&
centroid_y
=
source
.getProperty<
PixelCentroid
>().getCentroidY();
41
const
auto
&
coordinates
=
source
.getProperty<
PixelCoordinateList
>().getCoordinateList();
42
auto
total_intensity
=
source
.getProperty<
ShapeParameters
>().getIntensity();
43
auto
singu
=
source
.getProperty<
ShapeParameters
>().getSinguFlag();
44
45
SeFloat
x_2_error
= 0.0;
46
SeFloat
y_2_error
= 0.0;
47
SeFloat
x_y_error
= 0.0;
48
49
SeFloat
total_variance
= 0;
50
51
auto
j
=
pixel_variances
.begin();
52
for
(
auto
pixel_coord
:
coordinates
) {
53
SeFloat
variance
= *
j
++;
54
SeFloat
x_pos
=
pixel_coord
.m_x -
centroid_x
;
55
SeFloat
y_pos
=
pixel_coord
.m_y -
centroid_y
;
56
57
x_2_error
+=
x_pos
*
x_pos
*
variance
;
58
y_2_error
+=
y_pos
*
y_pos
*
variance
;
59
x_y_error
+=
x_pos
*
y_pos
*
variance
;
60
61
total_variance
+=
variance
;
62
}
63
64
SeFloat
total_intensity_2
=
total_intensity
*
total_intensity
;
65
x_2_error
/=
total_intensity_2
;
66
y_2_error
/=
total_intensity_2
;
67
x_y_error
/=
total_intensity_2
;
68
69
//esum *= 0.08333/flux2; // from the original SE2 code
70
total_variance
*= 0.08333/
total_intensity_2
;
71
// handle fully correlated x/y
72
if
(
singu
&& (
x_2_error
*
y_2_error
-
x_y_error
*
x_y_error
)<
total_variance
*
total_variance
) {
73
x_2_error
+=
total_variance
;
74
y_2_error
+=
total_variance
;
75
}
76
77
/*------------------------- Error ellipse parameters ------------------------*/
78
/* if (FLAG(obj2.poserr_a))
79
{
80
double pmx2,pmy2,temp,theta;
81
82
if (fabs(temp=obj->poserr_mx2-obj->poserr_my2) > 0.0)
83
theta = atan2(2.0 * obj->poserr_mxy,temp) / 2.0;
84
else
85
theta = PI/4.0;
86
87
temp = sqrt(0.25*temp*temp+obj->poserr_mxy*obj->poserr_mxy);
88
pmy2 = pmx2 = 0.5*(obj->poserr_mx2+obj->poserr_my2);
89
pmx2+=temp;
90
pmy2-=temp;
91
92
obj2->poserr_a = (float)sqrt(pmx2);
93
obj2->poserr_b = (float)sqrt(pmy2);
94
obj2->poserr_theta = theta*180.0/PI;
95
}
96
*/
97
98
// angle of the error ellipse
99
SeFloat
theta_error
,
a_error
,
b_error
;
100
SeFloat
temp_error
=
fabs
(
x_2_error
-
y_2_error
);
101
if
(
temp_error
>0.0)
102
theta_error
=
atan2
(2.0*
x_y_error
,
temp_error
);
// when dividing by 2.0 as in SE2 the range is -45 < theta_error < 45 which is smaller than in SE2
103
else
104
theta_error
=
M_PI
/4.0;
105
106
// major/minor axis for the error ellipse
107
temp_error
=
sqrt
(0.25*
temp_error
*
temp_error
+
x_y_error
*
x_y_error
);
108
a_error
= 0.5*(
x_2_error
+
y_2_error
);
109
b_error
=
a_error
;
110
a_error
=
sqrt
(
a_error
+
temp_error
);
111
b_error
=
sqrt
(
b_error
-
temp_error
);
112
113
// set the property
114
source
.setProperty<
ErrorEllipse
>(
a_error
,
b_error
,
theta_error
,
x_2_error
,
y_2_error
,
x_y_error
);
115
}
116
117
118
}
DetectionFramePixelValues.h
ErrorEllipseTask.h
ErrorEllipse.h
PeakValue.h
PixelCentroid.h
PixelCoordinateList.h
ShapeParameters.h
std::atan2
T atan2(T... args)
SourceXtractor::DetectionFramePixelValues
The values of a Source's pixels in the detection image. They are returned as a vector in the same ord...
Definition
DetectionFramePixelValues.h:39
SourceXtractor::ErrorEllipseTask::computeProperties
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition
ErrorEllipseTask.cpp:37
SourceXtractor::ErrorEllipse
Definition
ErrorEllipse.h:32
SourceXtractor::PixelCentroid
The centroid of all the pixels in the source, weighted by their DetectionImage pixel values.
Definition
PixelCentroid.h:37
SourceXtractor::PixelCoordinateList
Definition
PixelCoordinateList.h:33
SourceXtractor::ShapeParameters
Definition
ShapeParameters.h:32
SourceXtractor::SourceInterface
The SourceInterface is an abstract "source" that has properties attached to it.
Definition
SourceInterface.h:46
std::fabs
T fabs(T... args)
std::function
SourceXtractor
Definition
Aperture.h:30
std::sqrt
T sqrt(T... args)
Generated by
1.10.0