SourceXtractorPlusPlus  0.11
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 
ImageBase.h
SourceXtractor::PIXTYPE
float PIXTYPE
Definition: BackgroundDefine.h:30
std::string
STL class.
std::shared_ptr
STL class.
SourceXtractor::TypedSplineModelWrapper::create
static std::shared_ptr< TypedSplineModelWrapper< T > > create(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)
Definition: TypedSplineModelWrapper.h:50
SourceXtractor::TypedSplineModelWrapper::getWidth
int getWidth() const override
Returns the width of the image in pixels.
Definition: TypedSplineModelWrapper.h:65
SourceXtractor::TypedSplineModelWrapper::~TypedSplineModelWrapper
virtual ~TypedSplineModelWrapper()
Definition: TypedSplineModelWrapper.h:44
SourceXtractor::SplineModel
Definition: SplineModel.h:33
SourceXtractor::TypedSplineModelWrapper::saveTile
void saveTile(ImageTile< T > &) override
Definition: TypedSplineModelWrapper.h:97
path
boost::filesystem::path path
SourceXtractor::ImageTile
Definition: ImageTile.h:57
SourceXtractor::SplineModel::getMedian
PIXTYPE & getMedian()
Definition: SplineModel.cpp:80
SourceXtractor::TypedSplineModelWrapper::getRepr
std::string getRepr() const override
Human readable representation.
Definition: TypedSplineModelWrapper.h:55
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::TypedSplineModelWrapper::getValue
T getValue(int x, int y) const
Returns the value of the pixel with the coordinates (x,y)
Definition: TypedSplineModelWrapper.h:60
SourceXtractor::TypedSplineModelWrapper::getHeight
int getHeight() const override
Returns the height of the image in pixels.
Definition: TypedSplineModelWrapper.h:70
SourceXtractor::ImageSource
Definition: ImageSource.h:41
SourceXtractor::TypedSplineModelWrapper::getMedian
T getMedian() const
Returns the median of the spline.
Definition: TypedSplineModelWrapper.h:75
SourceXtractor::SplineModel::getNaxes
size_t * getNaxes()
Definition: SplineModel.cpp:76
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::SplineModel::getValue
PIXTYPE getValue(size_t x, size_t y)
Definition: SplineModel.cpp:276
SourceXtractor::SplineModel::gridToFits
void gridToFits(boost::filesystem::path &fitsName, const bool overwrite=true)
Definition: SplineModel.cpp:105
SourceXtractor::TypedSplineModelWrapper::getImageTile
std::shared_ptr< ImageTile< T > > getImageTile(int x, int y, int width, int height) const override
Definition: TypedSplineModelWrapper.h:79
ImageSource.h
SplineModel.h
SourceXtractor::TypedSplineModelWrapper::TypedSplineModelWrapper
TypedSplineModelWrapper(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)
Definition: TypedSplineModelWrapper.h:102
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::TypedSplineModelWrapper
Definition: TypedSplineModelWrapper.h:36
SourceXtractor::TypedSplineModelWrapper::gridToFits
void gridToFits(boost::filesystem::path path) const
Definition: TypedSplineModelWrapper.h:93
SourceXtractor::TypedSplineModelWrapper::m_spline_model
SplineModel * m_spline_model
Definition: TypedSplineModelWrapper.h:105