SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Plugin
ShapeParameters
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
26
#include "
SEImplementation/Property/PixelCoordinateList.h
"
27
#include "
SEImplementation/Plugin/DetectionFramePixelValues/DetectionFramePixelValues.h
"
28
#include "
SEImplementation/Plugin/ShapeParameters/ShapeParameters.h
"
29
#include "
SEImplementation/Plugin/PixelCentroid/PixelCentroid.h
"
30
#include "
SEImplementation/Plugin/PeakValue/PeakValue.h
"
31
32
#include "
SEImplementation/Plugin/ShapeParameters/ShapeParametersTask.h
"
33
34
namespace
SourceXtractor
{
35
36
void
ShapeParametersTask::computeProperties
(
SourceInterface
&
source
)
const
{
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
48
SeFloat
total_intensity
= 0;
49
50
DetectionImage::PixelType
half_peak_threshold
= (
peak_value
+
min_value
) / 2.0;
51
int
nb_of_pixels_above_half
= 0;
52
int
nb_of_pixels
=
coordinates
.size();
53
54
auto
i
=
pixel_values
.begin();
55
for
(
auto
pixel_coord
:
coordinates
) {
56
SeFloat
value = *
i
++;
57
SeFloat
x_pos
=
pixel_coord
.m_x -
centroid_x
;
58
SeFloat
y_pos
=
pixel_coord
.m_y -
centroid_y
;
59
60
if
(value >
half_peak_threshold
) {
61
nb_of_pixels_above_half
++;
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
71
x_2
/=
total_intensity
;
72
y_2
/=
total_intensity
;
73
x_y
/=
total_intensity
;
74
75
SeFloat
theta
;
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
101
SeFloat
area_under_half
= (
double
)
pixel_values
.size() -
nb_of_pixels_above_half
;
102
SeFloat
t1t2
=
min_value
/
half_peak_threshold
;
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
113
source
.setProperty<
ShapeParameters
>(a, b,
theta
,
abcor
,
cxx
,
cyy
,
cxy
,
nb_of_pixels
,
total_intensity
,
singu
);
114
}
115
116
117
}
DetectionFramePixelValues.h
PeakValue.h
PixelCentroid.h
PixelCoordinateList.h
ShapeParametersTask.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::PeakValue
Definition
PeakValue.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::ShapeParametersTask::computeProperties
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition
ShapeParametersTask.cpp:36
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
std::log
T log(T... args)
SourceXtractor
Definition
Aperture.h:30
std::sqrt
T sqrt(T... args)
Generated by
1.10.0