SourceXtractorPlusPlus  0.12
Please provide a description of the project.
TypedSplineModelWrapper.h
Go to the documentation of this file.
1 
17 /*
18  * Created on Jan 05, 2015
19  * @author: mkuemmel@usm.lmu.de
20  *
21  * Date: $Date$
22  * Revision: $Revision$
23  * Author: $Author$
24  */
25 #ifndef TYPEDSPLINEMODELWRAPPER_H
26 #define TYPEDSPLINEMODELWRAPPER_H
27 
28 #include <boost/filesystem.hpp>
32 
33 namespace SourceXtractor {
34 
35 template <typename T>
36 class TypedSplineModelWrapper final : public ImageSource<T> {
37 
38 public:
39 
40  //TypedSplineModelWrapper(const size_t* naxes, const size_t* gridCellSize, const size_t* nGrid, PIXTYPE* gridData){
41  // m_spline_model = new SplineModel(naxes, gridCellSize, nGrid, gridData);
42  //};
43 
45  if (m_spline_model){
46  delete m_spline_model;
47  }
48  };
49 
50  static std::shared_ptr<TypedSplineModelWrapper<T>> create(const size_t* naxes, const size_t* gridCellSize, const size_t* nGrid, PIXTYPE* gridData) {
51  return std::shared_ptr<TypedSplineModelWrapper<T>>(new TypedSplineModelWrapper<T>(naxes, gridCellSize, nGrid, gridData));
52  }
53 
55  std::string getRepr() const override {
56  return "TypedSplineModel";
57  }
58 
60  T getValue(int x, int y) const {
61  return (T)m_spline_model->getValue((size_t)x, (size_t)y);
62  };
63 
65  int getWidth() const override {
66  return (int)(m_spline_model->getNaxes())[0];
67  };
68 
70  int getHeight() const override {
71  return (int)(m_spline_model->getNaxes())[1];
72  };
73 
75  T getMedian() const {
76  return (T)m_spline_model->getMedian();
77  };
78 
79  std::shared_ptr<ImageTile<T>> getImageTile(int x, int y, int width, int height) const override {
80  auto tile = std::make_shared<ImageTile<T>>(x, y, width, height);
81  // Splines are calculated and cached per row. We fill
82  // the tile with the Y axis on the outer loop, so we can
83  // benefit from that caching
84  // @see SplineModel::getValue
85  for (auto j = y; j < y + height; ++j) {
86  for (auto i = x; i < x + width; ++i) {
87  tile->setValue(i, j, getValue(i, j));
88  }
89  }
90  return tile;
91  }
92 
93  void gridToFits(boost::filesystem::path path) const {
95  }
96 
97  void saveTile(ImageTile<T>& /*tile*/) override {
98  assert(false);
99  }
100 
101 private:
102  TypedSplineModelWrapper(const size_t* naxes, const size_t* gridCellSize, const size_t* nGrid, PIXTYPE* gridData){
103  m_spline_model = new SplineModel(naxes, gridCellSize, nGrid, gridData);
104  };
106 };
107 
108 } // end of namespace SourceXtractor
109 
110 #endif // TYPEDSPLINEMODELWRAPPER_H
111 
static std::shared_ptr< TypedSplineModelWrapper< T > > create(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
void saveTile(ImageTile< T > &) override
int getWidth() const override
Returns the width of the image in pixels.
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
STL class.
std::string getRepr() const override
Human readable representation.
boost::filesystem::path path
std::shared_ptr< ImageTile< T > > getImageTile(int x, int y, int width, int height) const override
PIXTYPE getValue(size_t x, size_t y)
void gridToFits(boost::filesystem::path &fitsName, const bool overwrite=true)
T getValue(int x, int y) const
Returns the value of the pixel with the coordinates (x,y)
T getMedian() const
Returns the median of the spline.
int getHeight() const override
Returns the height of the image in pixels.
void gridToFits(boost::filesystem::path path) const
TypedSplineModelWrapper(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)