SourceXtractorPlusPlus  0.10
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CompactExponentialModel.icpp
Go to the documentation of this file.
1 /*
2  * CompactExponentialModel.icpp
3  *
4  * Created on: Aug 19, 2019
5  * Author: mschefer
6  */
7 
8 namespace ModelFitting {
9 
10 template<typename ImageType>
12  double sharp_radius,
18  : CompactModelBase<ImageType>(x_scale, y_scale, rotation, width, height, x, y, transform),
19  m_sharp_radius_squared(float(sharp_radius * sharp_radius)),
20  m_i0(i0), m_k(k)
21 {}
22 
23 template<typename ImageType>
24 double CompactExponentialModel<ImageType>::getValue(double x, double y) const {
25  ExponentialModelEvaluator model_info;
26  model_info.transform = getCombinedTransform(1.0);
27  model_info.i0 = m_i0->getValue();
28  model_info.k = m_k->getValue();
29 
30  auto area_correction = (1.0 / fabs(m_jacobian[0] * m_jacobian[3] - m_jacobian[1] * m_jacobian[2]));
31  return model_info.evaluateModel(x, y) * area_correction;
32 }
33 
34 template<typename ImageType>
36  //std::cout << "]] " << getX() << " " << getY() << "\n";
38 
39  if (size_x % 2 == 0 || size_y % 2 == 0) {
40  throw Elements::Exception() << "Rasterized image dimensions must be odd numbers "
41  << "but got (" << size_x << ',' << size_y << ")";
42  }
43 
44  ImageType image = Traits::factory(size_x, size_y);
45 
46  ExponentialModelEvaluator model_eval;
47  model_eval.transform = getCombinedTransform(pixel_scale);
48  model_eval.i0 = m_i0->getValue();
49  model_eval.k = m_k->getValue();
50 
51  float area_correction = (1.0 / fabs(m_jacobian[0] * m_jacobian[3] - m_jacobian[1] * m_jacobian[2])) * pixel_scale * pixel_scale;
52 
53  for (int x=0; x<(int)size_x; ++x) {
54  int dx = x - size_x / 2;
55  for (int y=0; y<(int)size_y; ++y) {
56  int dy = y - size_y / 2;
57  if (dx*dx + dy*dy < m_sharp_radius_squared) {
58  Traits::at(image, x, y) = adaptiveSamplePixel(model_eval, dx, dy, 8, 1.01) * area_correction;
59  } else {
60  Traits::at(image, x, y) = model_eval.evaluateModel(dx, dy) * area_correction;
61  }
62  }
63  }
64 
65  return image;
66 }
67 
68 }
69 
ImageType getRasterizedImage(double pixel_scale, std::size_t size_x, std::size_t size_y) const override
T fabs(T...args)
ModelFitting::ImageTraits< ImageInterfaceTypePtr > Traits
CompactExponentialModel(double sharp_radius, std::shared_ptr< BasicParameter > i0, std::shared_ptr< BasicParameter > k, std::shared_ptr< BasicParameter > x_scale, std::shared_ptr< BasicParameter > y_scale, std::shared_ptr< BasicParameter > rotation, double width, double height, std::shared_ptr< BasicParameter > x, std::shared_ptr< BasicParameter > y, std::tuple< double, double, double, double > transform)
std::shared_ptr< EngineParameter > dx
const double pixel_scale
Definition: TestImage.cpp:75
std::pair< double, double > transform(int x, int y, const std::array< double, 4 > &t)
double getValue(double x, double y) const override
std::shared_ptr< EngineParameter > dy