SourceXtractorPlusPlus  0.10
Please provide a description of the project.
AutoSharp.cpp
Go to the documentation of this file.
1 
23 #include <cmath> // For std::abs, std::ceil
24 #include <algorithm> // For std::min, std::max
26 
27 namespace ModelFitting {
28 
29 AutoSharp::AutoSharp(double log_incr, double first_r, double tolerance, double min_sampling_factor)
30  : m_log_incr {log_incr}, m_first_r{first_r}, m_tolerance{tolerance},
31  m_min_sampling_factor{min_sampling_factor} {
32 }
33 
34 AutoSharp::~AutoSharp() = default;
35 
36 void AutoSharp::updateRasterizationInfo(double scale, double r_max, Profile profile) {
37  m_r_sharp = 0.;
38  double err = m_tolerance;
39  while (m_r_sharp < r_max && err >= m_tolerance) {
40  double v1 = profile(m_r_sharp);
41  double v2 = profile(m_r_sharp + scale / 2.);
42  double v3 = profile(m_r_sharp + scale);
43  err = std::abs((v2 - (v3 + v1) / 2) / v2);
44  m_r_sharp += scale;
45  }
46  m_r_sharp = std::min(m_r_sharp, r_max);
47  m_r_sharp = std::max(m_r_sharp, 4 * scale);
49  m_first_pix_r = scale / 2.;
50 }
51 
53  return r < m_r_sharp;
54 }
55 
57  double next_r = prev_r > 0
58  ? std::min(prev_r * m_log_incr, prev_r + m_max_step)
59  : m_first_r;
60  int angle_no = next_r > m_first_pix_r
61  ? std::ceil(2. * M_PI * prev_r / m_max_step)
62  : 1;
63  return std::make_pair(next_r, angle_no);
64 }
65 
66 } // end of namespace ModelFitting
AutoSharp(double log_incr=1.122, double first_r=1E-4, double tolerance=0.05, double min_sampling_factor=5.)
Definition: AutoSharp.cpp:29
bool insideSharpRegion(double r) override
Definition: AutoSharp.cpp:52
T ceil(T... args)
T min(T... args)
T make_pair(T... args)
T max(T... args)
void updateRasterizationInfo(double scale, double r_max, Profile profile) override
Definition: AutoSharp.cpp:36
std::pair< double, int > nextRadiusAndAngleNo(double prev_r) override
Definition: AutoSharp.cpp:56
double m_min_sampling_factor
Definition: AutoSharp.h:76