SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEImplementation
src
lib
Plugin
KronRadius
KronRadiusTask.cpp
Go to the documentation of this file.
1
17
/*
18
* KronRadiusTask.cpp
19
*
20
* Created on: Sep 12, 2016
21
* Author: mkuemmel@usm.lmu.de
22
*/
23
24
#include <math.h>
25
26
#include "
SEFramework/Aperture/EllipticalAperture.h
"
27
#include "
SEFramework/Aperture/NeighbourInfo.h
"
28
29
#include "
SEImplementation/Property/PixelCoordinateList.h
"
30
#include "
SEImplementation/Plugin/PixelCentroid/PixelCentroid.h
"
31
#include "
SEImplementation/Plugin/ShapeParameters/ShapeParameters.h
"
32
#include "
SEImplementation/Plugin/AutoPhotometry/AutoPhotometryTask.h
"
33
#include "
SEImplementation/Plugin/AperturePhotometry/AperturePhotometryTask.h
"
34
#include "
SEImplementation/Plugin/DetectionFrameInfo/DetectionFrameInfo.h
"
35
#include "
SEImplementation/Plugin/DetectionFrameImages/DetectionFrameImages.h
"
36
37
#include "
SEImplementation/Plugin/KronRadius/KronRadius.h
"
38
#include "
SEImplementation/Plugin/KronRadius/KronRadiusTask.h
"
39
40
namespace
SourceXtractor
{
41
42
namespace
{
43
// the typical radius for determining the Kron-radius
44
const
SeFloat
KRON_NRADIUS = 3*2.0;
45
const
SeFloat
CROWD_THRESHOLD_KRON = 0.1;
46
const
SeFloat
BADAREA_THRESHOLD_KRON = 0.1;
47
}
48
50
51
void
KronRadiusTask::computeProperties
(
SourceInterface
&
source
)
const
{
52
// get the detection frame info
53
const
auto
&
detection_frame_info
=
source
.getProperty<
DetectionFrameInfo
>();
54
const
auto
variance_threshold
=
detection_frame_info
.getVarianceThreshold();
55
56
// get detection frame images
57
const
auto
&
detection_frame_images
=
source
.getProperty<
DetectionFrameImages
>();
58
59
const
auto
detection_image
=
detection_frame_images
.getLockedImage(
LayerSubtractedImage
);
60
const
auto
detection_variance
=
detection_frame_images
.getLockedImage(
LayerVarianceMap
);
61
const
auto
threshold_image
=
detection_frame_images
.getLockedImage(
LayerThresholdedImage
);
62
63
64
// get the object center
65
const
auto
&
centroid_x
=
source
.getProperty<
PixelCentroid
>().getCentroidX();
66
const
auto
&
centroid_y
=
source
.getProperty<
PixelCentroid
>().getCentroidY();
67
68
// get the shape parameters
69
const
auto
&
cxx
=
source
.getProperty<
ShapeParameters
>().getEllipseCxx();
70
const
auto
&
cyy
=
source
.getProperty<
ShapeParameters
>().getEllipseCyy();
71
const
auto
&
cxy
=
source
.getProperty<
ShapeParameters
>().getEllipseCxy();
72
73
// create the elliptical aperture
74
auto
ell_aper
=
std::make_shared<EllipticalAperture>
(
cxx
,
cyy
,
cxy
,
KRON_NRADIUS
);
75
76
// get the aperture borders on the image
77
const
auto
&
min_pixel
=
ell_aper
->getMinPixel(
centroid_x
,
centroid_y
);
78
const
auto
&
max_pixel
=
ell_aper
->getMaxPixel(
centroid_x
,
centroid_y
);
79
80
// get the pixel list
81
const
auto
&
pix_list
=
source
.getProperty<
PixelCoordinateList
>().getCoordinateList();
82
83
// get the neighbourhood information
84
NeighbourInfo
neighbour_info
(
min_pixel
,
max_pixel
,
pix_list
,
threshold_image
);
85
86
SeFloat
radius_flux_sum
= 0.;
87
SeFloat
flux_sum
= 0.;
88
SeFloat
area_sum
= 0;
89
SeFloat
area_bad
= 0;
90
SeFloat
area_full
= 0;
91
long
int
flag
= 0;
92
93
// iterate over the aperture pixels
94
for
(
int
pixel_y
=
min_pixel
.m_y;
pixel_y
<=
max_pixel
.m_y;
pixel_y
++) {
95
for
(
int
pixel_x
=
min_pixel
.m_x;
pixel_x
<=
max_pixel
.m_x;
pixel_x
++) {
96
97
// check whether the current pixel is inside
98
SeFloat
area
=
ell_aper
->getArea(
centroid_x
,
centroid_y
,
pixel_x
,
pixel_y
);
99
if
(
area
<= 0) {
100
continue
;
101
}
102
103
// make sure the pixel is inside the image
104
if
(
detection_image
->isInside(
pixel_x
,
pixel_y
)) {
105
SeFloat
value = 0;
106
107
// enhance the area
108
area_sum
+= 1;
109
110
// get the variance value
111
auto
pixel_variance
=
detection_variance
->getValue(
pixel_x
,
pixel_y
);
112
113
// check whether the pixel is good
114
bool
is_good
=
pixel_variance
<
variance_threshold
;
115
value =
detection_image
->getValue(
pixel_x
,
pixel_y
) *
is_good
;
116
area_bad
+= !
is_good
;
117
118
// check whether the pixel is part of another object
119
if
(
neighbour_info
.isNeighbourObjectPixel(
pixel_x
,
pixel_y
)) {
120
area_full
+= 1;
121
}
122
else
{
123
// add the pixel quantity
124
radius_flux_sum
+= value *
sqrt
(
ell_aper
->getRadiusSquared(
centroid_x
,
centroid_y
,
pixel_x
,
pixel_y
));
125
flux_sum
+= value;
126
}
127
}
128
else
{
129
// set the border flag
130
flag
|= 0x0008;
131
}
132
}
133
}
134
135
// check/set the bad area flag
136
bool
bad_threshold
=
area_sum
> 0 &&
area_bad
/
area_sum
>
BADAREA_THRESHOLD_KRON
;
137
flag
|= 0x0001 *
bad_threshold
;
138
139
// check/set the crowded area flag
140
bool
crowded
=
area_sum
> 0 &&
area_full
/
area_sum
>
CROWD_THRESHOLD_KRON
;
141
flag
|=
crowded
;
142
143
// set the property
144
source
.setProperty<
KronRadius
>(
flux_sum
> 0 ?
radius_flux_sum
/
flux_sum
: 0,
flag
);
145
}
146
}
147
AperturePhotometryTask.h
AutoPhotometryTask.h
DetectionFrameImages.h
DetectionFrameInfo.h
EllipticalAperture.h
KronRadiusTask.h
KronRadius.h
NeighbourInfo.h
PixelCentroid.h
PixelCoordinateList.h
ShapeParameters.h
SourceXtractor::DetectionFrameImages
Definition
DetectionFrameImages.h:30
SourceXtractor::DetectionFrameInfo
Definition
DetectionFrameInfo.h:29
SourceXtractor::KronRadiusTask::computeProperties
void computeProperties(SourceInterface &source) const override
Computes one or more properties for the Source.
Definition
KronRadiusTask.cpp:51
SourceXtractor::KronRadius
Kron radius.
Definition
KronRadius.h:36
SourceXtractor::NeighbourInfo
Definition
NeighbourInfo.h:34
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::function
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::LayerVarianceMap
@ LayerVarianceMap
Definition
Frame.h:45
SourceXtractor::LayerThresholdedImage
@ LayerThresholdedImage
Definition
Frame.h:41
SourceXtractor::LayerSubtractedImage
@ LayerSubtractedImage
Definition
Frame.h:39
SourceXtractor::SeFloat
SeFloat32 SeFloat
Definition
Types.h:32
std::sqrt
T sqrt(T... args)
Generated by
1.10.0