SourceXtractorPlusPlus 1.0.3
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
Flagging.cpp
Go to the documentation of this file.
1
17
18
19
21
22namespace SourceXtractor {
23
26
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
Interface representing an image.
Definition Image.h:44
bool isNeighbourObjectPixel(int x, int y) const
const SeFloat BADAREA_THRESHOLD_APER
Definition Flagging.cpp:25
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
Flags
Flagging of bad sources.
Definition SourceFlags.h:37
@ NEIGHBORS
The object has neighbors, bright and close enough.
Definition SourceFlags.h:43
@ BOUNDARY
The object is truncated (too close to an image boundary).
Definition SourceFlags.h:42
@ NONE
No flag is set.
Definition SourceFlags.h:38
@ BIASED
The object has bad pixels.
Definition SourceFlags.h:39
SeFloat32 SeFloat
Definition Types.h:32
const SeFloat CROWD_THRESHOLD_APER
Definition Flagging.cpp:24