SourceXtractorPlusPlus  0.15
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CircularAperture.cpp
Go to the documentation of this file.
1 
17 /*
18  * CircularAperture.cpp
19  *
20  * Created on: Oct 08, 2018
21  * Author: Alejandro Alvarez
22  */
23 
25 
26 namespace SourceXtractor {
27 
28 // enhancing from 5 to 10 smoothens the photometry
29 const int SUPERSAMPLE_NB = 10;
30 
31 SeFloat CircularAperture::getArea(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const {
32  auto dx = pixel_x - center_x;
33  auto dy = pixel_y - center_y;
34  SeFloat min_supersampled_radius_squared = m_radius > .75 ? (m_radius - .75) * (m_radius - .75) : 0;
35  SeFloat max_supersampled_radius_squared = (m_radius + .75) * (m_radius + .75);
36 
37  auto distance_squared = dx * dx + dy * dy;
38  SeFloat area = 0.0;
39  if (distance_squared < min_supersampled_radius_squared) {
40  area = 1.0;
41  }
42  else if (distance_squared <= max_supersampled_radius_squared) {
43  for (int sub_y = 0; sub_y < SUPERSAMPLE_NB; sub_y++) {
44  for (int sub_x = 0; sub_x < SUPERSAMPLE_NB; sub_x++) {
45  auto dx2 = dx + SeFloat(sub_x - SUPERSAMPLE_NB / 2) / SUPERSAMPLE_NB;
46  auto dy2 = dy + SeFloat(sub_y - SUPERSAMPLE_NB / 2) / SUPERSAMPLE_NB;
47  auto supersampled_distance_squared = dx2 * dx2 + dy2 * dy2;
48  if (supersampled_distance_squared <= m_radius * m_radius) {
49  area += 1.0 / (SUPERSAMPLE_NB * SUPERSAMPLE_NB);
50  }
51  }
52  }
53  }
54  return area;
55 }
56 
57 SeFloat CircularAperture::getRadiusSquared(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const {
58  auto dist_x = SeFloat(pixel_x) - center_x;
59  auto dist_y = SeFloat(pixel_y) - center_y;
60 
61  return dist_x * dist_x + dist_y * dist_y;
62 }
63 
65  return PixelCoordinate(centroid_x - m_radius, centroid_y - m_radius);
66 }
67 
69  return PixelCoordinate(std::ceil(centroid_x + m_radius), std::ceil(centroid_y + m_radius));
70 }
71 
72 } // end SourceXtractor
PixelCoordinate getMaxPixel(SeFloat centroid_x, SeFloat centroid_y) const override
T ceil(T...args)
SeFloat32 SeFloat
Definition: Types.h:32
SeFloat getRadiusSquared(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const override
const int SUPERSAMPLE_NB
A pixel coordinate made of two integers m_x and m_y.
PixelCoordinate getMinPixel(SeFloat centroid_x, SeFloat centroid_y) const override
SeFloat getArea(SeFloat center_x, SeFloat center_y, SeFloat pixel_x, SeFloat pixel_y) const override
std::shared_ptr< EngineParameter > dx
std::shared_ptr< EngineParameter > dy