SourceXtractorPlusPlus  0.15
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FrameModel.h
Go to the documentation of this file.
1 
23 #ifndef MODELFITTING_FRAMEMODEL_H
24 #define MODELFITTING_FRAMEMODEL_H
25 
26 #include <vector>
27 #include <cmath>
33 
34 namespace ModelFitting {
35 
42 template <typename PsfType>
43 class FrameModelPsfContainer: public PsfType {
44 public:
45 
51  FrameModelPsfContainer(std::size_t n_extended_models);
52 
60  FrameModelPsfContainer(PsfType psf, std::size_t n_extended_models);
61 
69  template <typename ImageType>
70  void convolve(size_t, ImageType& image) {
71  PsfType::convolve(image);
72  }
73 };
74 
81 template <typename PsfType>
82 class FrameModelPsfContextContainer: public PsfType {
83 public:
84 
90  FrameModelPsfContextContainer(std::size_t n_extended_models);
91 
99  FrameModelPsfContextContainer(PsfType psf, std::size_t n_extended_models);
100 
110  template <typename ImageType>
111  void convolve(size_t i, ImageType& image) {
112  auto& context = m_psf_contexts[i];
113  if (!context) {
114  context = PsfType::prepare(image);
115  }
116  PsfType::convolve(image, context);
117  }
118 
119 private:
121 };
122 
123 
124 template <typename PsfType, typename ImageType>
125 class FrameModel {
126 private:
127 
128  // PsfTraits must have a has_context boolean with the value of true
129  // if PsfType has a context type and a prepare method.
130  // If it is the case, the PSF will be wrapped by FrameModelPsfContextContainer:
131  // each model will have its own context.
132  // Otherwise, the PSF will be just wrapped by FrameModelPsfContainer, which
133  // forwards directly the calls.
134  using psf_container_t = typename std::conditional<
138  >::type;
139 
140 public:
141 
143 
145  std::vector<ConstantModel> constant_model_list,
146  std::vector<PointModel> point_model_list,
148  PsfType psf);
149 
151  std::vector<ConstantModel> constant_model_list,
152  std::vector<PointModel> point_model_list,
154 
155 
156  FrameModel(FrameModel&&) = default;
157 
158  virtual ~FrameModel();
159 
160  void recomputeImage();
161 
162  const ImageType& getImage();
163 
164  void rasterToImage(ImageType&);
165 
167 
169 
170  std::size_t size() const;
171 
172 private:
173 
182 
183 }; // end of class FrameModel
184 
185 } // end of namespace ModelFitting
186 
187 #include "_impl/FrameModel.icpp"
188 
189 #endif /* MODELFITTING_FRAMEMODEL_H */
190 
std::vector< PointModel > m_point_model_list
Definition: FrameModel.h:178
typename ImageTraits< ImageType >::iterator const_iterator
Definition: FrameModel.h:142
std::unique_ptr< ImageType > m_model_image
Definition: FrameModel.h:181
FrameModelPsfContainer(std::size_t n_extended_models)
Definition: FrameModel.icpp:26
void convolve(size_t i, ImageType &image)
Definition: FrameModel.h:111
FrameModel(double pixel_scale, std::size_t width, std::size_t height, std::vector< ConstantModel > constant_model_list, std::vector< PointModel > point_model_list, std::vector< std::shared_ptr< ExtendedModel< ImageType >>> extended_model_list, PsfType psf)
Definition: FrameModel.icpp:40
typename std::conditional< PsfTraits< PsfType >::has_context, FrameModelPsfContextContainer< PsfType >, FrameModelPsfContainer< PsfType > >::type psf_container_t
Definition: FrameModel.h:138
const ImageType & getImage()
const_iterator begin()
std::vector< ConstantModel > m_constant_model_list
Definition: FrameModel.h:177
std::vector< typename PsfTraits< PsfType >::context_t > m_psf_contexts
Definition: FrameModel.h:120
FrameModelPsfContextContainer(std::size_t n_extended_models)
Definition: FrameModel.icpp:32
std::size_t size() const
psf_container_t m_psf
Definition: FrameModel.h:180
const_iterator end()
void convolve(size_t, ImageType &image)
Definition: FrameModel.h:70
STL class.
const double pixel_scale
Definition: TestImage.cpp:74
void rasterToImage(ImageType &)
std::vector< std::shared_ptr< ExtendedModel< ImageType > > > m_extended_model_list
Definition: FrameModel.h:179