SourceXtractorPlusPlus  0.8
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>
34 
35 namespace ModelFitting {
36 
43 template <typename PsfType>
44 class FrameModelPsfContainer: public PsfType {
45 public:
46 
52  FrameModelPsfContainer(std::size_t n_extended_models);
53 
61  FrameModelPsfContainer(PsfType psf, std::size_t n_extended_models);
62 
70  template <typename ImageType>
71  void convolve(size_t, ImageType& image) {
72  PsfType::convolve(image);
73  }
74 };
75 
82 template <typename PsfType>
83 class FrameModelPsfContextContainer: public PsfType {
84 public:
85 
91  FrameModelPsfContextContainer(std::size_t n_extended_models);
92 
100  FrameModelPsfContextContainer(PsfType psf, std::size_t n_extended_models);
101 
111  template <typename ImageType>
112  void convolve(size_t i, ImageType& image) {
113  auto& context = m_psf_contexts[i];
114  if (!context) {
115  context = PsfType::prepare(image);
116  }
117  PsfType::convolve(image, context);
118  }
119 
120 private:
122 };
123 
124 
125 template <typename PsfType, typename ImageType>
126 class FrameModel {
127 private:
128 
129  // PsfTraits must have a has_context boolean with the value of true
130  // if PsfType has a context type and a prepare method.
131  // If it is the case, the PSF will be wrapped by FrameModelPsfContextContainer:
132  // each model will have its own context.
133  // Otherwise, the PSF will be just wrapped by FrameModelPsfContainer, which
134  // forwards directly the calls.
135  using psf_container_t = typename std::conditional<
139  >::type;
140 
141 public:
142 
144 
145  FrameModel(double pixel_scale, std::size_t width, std::size_t height,
146  std::vector<ConstantModel> constant_model_list,
147  std::vector<PointModel> point_model_list,
148  std::vector<TransformedModel> extended_model_list,
149  PsfType psf);
150 
151  FrameModel(double pixel_scale, std::size_t width, std::size_t height,
152  std::vector<ConstantModel> constant_model_list,
153  std::vector<PointModel> point_model_list,
154  std::vector<TransformedModel> extended_model_list);
155 
156 
157  FrameModel(FrameModel&&) = default;
158 
159  virtual ~FrameModel();
160 
161  void recomputeImage();
162 
163  const ImageType& getImage();
164 
165  void rasterToImage(ImageType&);
166 
168 
170 
171  std::size_t size() const;
172 
173 private:
174 
183 
184 }; // end of class FrameModel
185 
186 } // end of namespace ModelFitting
187 
188 #include "_impl/FrameModel.icpp"
189 
190 #endif /* MODELFITTING_FRAMEMODEL_H */
191 
std::vector< PointModel > m_point_model_list
Definition: FrameModel.h:179
typename ImageTraits< ImageType >::iterator const_iterator
Definition: FrameModel.h:143
std::unique_ptr< ImageType > m_model_image
Definition: FrameModel.h:182
FrameModelPsfContainer(std::size_t n_extended_models)
Definition: FrameModel.icpp:26
void convolve(size_t i, ImageType &image)
Definition: FrameModel.h:112
std::vector< TransformedModel > m_extended_model_list
Definition: FrameModel.h:180
typename std::conditional< PsfTraits< PsfType >::has_context, FrameModelPsfContextContainer< PsfType >, FrameModelPsfContainer< PsfType > >::type psf_container_t
Definition: FrameModel.h:139
const ImageType & getImage()
const_iterator begin()
std::vector< ConstantModel > m_constant_model_list
Definition: FrameModel.h:178
std::vector< typename PsfTraits< PsfType >::context_t > m_psf_contexts
Definition: FrameModel.h:121
FrameModelPsfContextContainer(std::size_t n_extended_models)
Definition: FrameModel.icpp:32
std::size_t size() const
psf_container_t m_psf
Definition: FrameModel.h:181
const_iterator end()
void convolve(size_t, ImageType &image)
Definition: FrameModel.h:71
STL class.
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< TransformedModel > extended_model_list, PsfType psf)
Definition: FrameModel.icpp:40
const double pixel_scale
Definition: TestImage.cpp:72
void rasterToImage(ImageType &)