SourceXtractorPlusPlus  0.12
Please provide a description of the project.
Flagging.cpp
Go to the documentation of this file.
1 
21 
22 namespace 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  // get the aperture borders on the image
35  auto min_pixel = aperture->getMinPixel(centroid_x, centroid_y);
36  auto max_pixel = aperture->getMaxPixel(centroid_x, centroid_y);
37 
38  // get the neighbourhood information
39  NeighbourInfo neighbour_info(min_pixel, max_pixel, pix_list, threshold_image);
40 
41  Flags flag = Flags::NONE;
42  SeFloat total_area = 0.0;
43  SeFloat bad_area = 0;
44  SeFloat full_area = 0;
45 
46  // iterate over the aperture pixels
47  for (int pixel_y = min_pixel.m_y; pixel_y <= max_pixel.m_y; pixel_y++) {
48  for (int pixel_x = min_pixel.m_x; pixel_x <= max_pixel.m_x; pixel_x++) {
49 
50  // get the area coverage and continue if there is overlap
51  auto area = aperture->getArea(centroid_x, centroid_y, pixel_x, pixel_y);
52  if (area == 0) {
53  continue;
54  }
55 
56  // make sure the pixel is inside the image
57  if (detection_img->isInside(pixel_x, pixel_y)) {
58 
59  // enhance the area
60  total_area += area;
61 
62  full_area += neighbour_info.isNeighbourObjectPixel(pixel_x, pixel_y);
63  bad_area += (detection_variance->getValue(pixel_x, pixel_y) > variance_threshold);
64  }
65  else {
66  flag |= Flags::BOUNDARY;
67  }
68  }
69  }
70 
71  // check/set the bad area flag
72  if (total_area > 0 && bad_area / total_area > BADAREA_THRESHOLD_APER)
73  flag |= Flags::BIASED;
74 
75  // check/set the crowded area flag
76  if (total_area > 0 && full_area / total_area > CROWD_THRESHOLD_APER)
77  flag |= Flags::NEIGHBORS;
78 
79  return flag;
80 }
81 
82 } // end of namespace SourceXtractor
The object has neighbors, bright and close enough.
SeFloat32 SeFloat
Definition: Types.h:32
The object is truncated (too close to an image boundary)
The object has bad pixels.
bool isNeighbourObjectPixel(int x, int y) const
STL class.
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:34
Interface representing an image.
Definition: Image.h:43
const SeFloat BADAREA_THRESHOLD_APER
Definition: Flagging.cpp:25
const SeFloat CROWD_THRESHOLD_APER
Definition: Flagging.cpp:24