SourceXtractorPlusPlus
0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
SEFramework
src
lib
Aperture
Flagging.cpp
Go to the documentation of this file.
1
20
#include "
SEFramework/Aperture/Flagging.h
"
21
22
namespace
SourceXtractor
{
23
24
const
SeFloat
CROWD_THRESHOLD_APER
= 0.1;
25
const
SeFloat
BADAREA_THRESHOLD_APER
= 0.1;
26
27
Flags
computeFlags
(
const
std::shared_ptr<Aperture>
&
aperture
,
28
SeFloat
centroid_x
,
SeFloat
centroid_y
,
29
const
std::vector<PixelCoordinate>
&
pix_list
,
30
const
std::shared_ptr
<
Image<SeFloat>
>&
detection_img
,
31
const
std::shared_ptr
<
Image<SeFloat>
>&
detection_variance
,
32
const
std::shared_ptr
<
Image<SeFloat>
>&
threshold_image
,
33
SeFloat
variance_threshold
) {
34
35
Flags
flag
=
Flags::NONE
;
36
// get the aperture borders on the image
37
auto
min_pixel
=
aperture
->getMinPixel(
centroid_x
,
centroid_y
);
38
auto
max_pixel
=
aperture
->getMaxPixel(
centroid_x
,
centroid_y
);
39
40
// clip to the actual image
41
if
(
min_pixel
.clip(
detection_img
->getWidth(),
detection_img
->getHeight()))
42
flag
|=
Flags::BOUNDARY
;
43
if
(
max_pixel
.clip(
detection_img
->getWidth(),
detection_img
->getHeight()))
44
flag
|=
Flags::BOUNDARY
;
45
46
// cut the bit of image we need
47
auto
var_cutout
=
detection_variance
->getChunk(
min_pixel
,
max_pixel
);
48
49
// get the neighbourhood information
50
NeighbourInfo
neighbour_info
(
min_pixel
,
max_pixel
,
pix_list
,
threshold_image
);
51
52
SeFloat
total_area
= 0.0;
53
SeFloat
bad_area
= 0;
54
SeFloat
full_area
= 0;
55
56
// iterate over the aperture pixels
57
for
(
int
pixel_y
=
min_pixel
.m_y;
pixel_y
<=
max_pixel
.m_y;
pixel_y
++) {
58
for
(
int
pixel_x
=
min_pixel
.m_x;
pixel_x
<=
max_pixel
.m_x;
pixel_x
++) {
59
60
// get the area coverage and continue if there is overlap
61
auto
area
=
aperture
->getArea(
centroid_x
,
centroid_y
,
pixel_x
,
pixel_y
);
62
if
(
area
== 0) {
63
continue
;
64
}
65
66
total_area
+=
area
;
67
68
full_area
+=
neighbour_info
.isNeighbourObjectPixel(
pixel_x
,
pixel_y
);
69
bad_area
+= (
var_cutout
->getValue(
pixel_x
-
min_pixel
.m_x,
pixel_y
-
min_pixel
.m_y) >
70
variance_threshold
);
71
}
72
}
73
74
// check/set the bad area flag
75
if
(
total_area
> 0 &&
bad_area
/
total_area
>
BADAREA_THRESHOLD_APER
)
76
flag
|=
Flags::BIASED
;
77
78
// check/set the crowded area flag
79
if
(
total_area
> 0 &&
full_area
/
total_area
>
CROWD_THRESHOLD_APER
)
80
flag
|=
Flags::NEIGHBORS
;
81
82
return
flag
;
83
}
84
85
}
// end of namespace SourceXtractor
Flagging.h
SourceXtractor::NeighbourInfo
Definition
NeighbourInfo.h:34
std::function
SourceXtractor
Definition
Aperture.h:30
SourceXtractor::BADAREA_THRESHOLD_APER
const SeFloat BADAREA_THRESHOLD_APER
Definition
Flagging.cpp:25
SourceXtractor::computeFlags
Flags computeFlags(const std::shared_ptr< Aperture > &aperture, SeFloat centroid_x, SeFloat centroid_y, const std::vector< PixelCoordinate > &pix_list, const std::shared_ptr< Image< SeFloat > > &detection_img, const std::shared_ptr< Image< SeFloat > > &detection_variance, const std::shared_ptr< Image< SeFloat > > &threshold_image, SeFloat variance_threshold)
Definition
Flagging.cpp:27
SourceXtractor::Flags
Flags
Flagging of bad sources.
Definition
SourceFlags.h:37
SourceXtractor::Flags::NEIGHBORS
@ NEIGHBORS
The object has neighbors, bright and close enough.
SourceXtractor::Flags::BOUNDARY
@ BOUNDARY
The object is truncated (too close to an image boundary)
SourceXtractor::Flags::NONE
@ NONE
No flag is set.
SourceXtractor::Flags::BIASED
@ BIASED
The object has bad pixels.
SourceXtractor::SeFloat
SeFloat32 SeFloat
Definition
Types.h:32
SourceXtractor::CROWD_THRESHOLD_APER
const SeFloat CROWD_THRESHOLD_APER
Definition
Flagging.cpp:24
std::shared_ptr
Generated by
1.10.0