SourceXtractorPlusPlus  0.15
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 
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
SourceXtractor::Aperture::getMaxPixel
virtual PixelCoordinate getMaxPixel(SeFloat centroid_x, SeFloat centroid_y) const =0
std::shared_ptr
STL class.
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::SeFloat
SeFloat32 SeFloat
Definition: Types.h:32
std::vector
STL class.
SourceXtractor::Flags
Flags
Flagging of bad sources.
Definition: SourceFlags.h:37
SourceXtractor::Image< SeFloat >
SourceXtractor::NeighbourInfo::isNeighbourObjectPixel
bool isNeighbourObjectPixel(int x, int y) const
Definition: NeighbourInfo.cpp:64
SourceXtractor::CROWD_THRESHOLD_APER
const SeFloat CROWD_THRESHOLD_APER
Definition: Flagging.cpp:24
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::BADAREA_THRESHOLD_APER
const SeFloat BADAREA_THRESHOLD_APER
Definition: Flagging.cpp:25
Flagging.h
SourceXtractor::NeighbourInfo
Definition: NeighbourInfo.h:34
SourceXtractor::Aperture::getArea
virtual SeFloat getArea(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const =0
SourceXtractor::Aperture::getMinPixel
virtual PixelCoordinate getMinPixel(SeFloat centroid_x, SeFloat centroid_y) const =0