SourceXtractorPlusPlus  0.16
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>
31 
32 namespace SourceXtractor {
33 
34 template <typename T>
35 class TypedSplineModelWrapper final : public ImageSource {
36 
37 public:
38 
39  //TypedSplineModelWrapper(const size_t* naxes, const size_t* gridCellSize, const size_t* nGrid, PIXTYPE* gridData){
40  // m_spline_model = new SplineModel(naxes, gridCellSize, nGrid, gridData);
41  //};
42 
44  if (m_spline_model){
45  delete m_spline_model;
46  }
47  };
48 
49  static std::shared_ptr<TypedSplineModelWrapper<T>> create(const size_t* naxes, const size_t* gridCellSize, const size_t* nGrid, PIXTYPE* gridData) {
50  return std::shared_ptr<TypedSplineModelWrapper<T>>(new TypedSplineModelWrapper<T>(naxes, gridCellSize, nGrid, gridData));
51  }
52 
54  std::string getRepr() const override {
55  return "TypedSplineModel";
56  }
57 
59  T getValue(int x, int y) const {
60  return (T)m_spline_model->getValue((size_t)x, (size_t)y);
61  };
62 
64  int getWidth() const override {
65  return (int)(m_spline_model->getNaxes())[0];
66  };
67 
69  int getHeight() const override {
70  return (int)(m_spline_model->getNaxes())[1];
71  };
72 
74  T getMedian() const {
75  return (T)m_spline_model->getMedian();
76  };
77 
78  std::shared_ptr<ImageTile> getImageTile(int x, int y, int width, int height) const override {
79  auto tile = ImageTile::create(ImageTile::getTypeValue(T()), x, y, width, height);
80  // Splines are calculated and cached per row. We fill
81  // the tile with the Y axis on the outer loop, so we can
82  // benefit from that caching
83  // @see SplineModel::getValue
84  for (auto j = y; j < y + height; ++j) {
85  for (auto i = x; i < x + width; ++i) {
86  tile->setValue(i, j, getValue(i, j));
87  }
88  }
89  return tile;
90  }
91 
92  void gridToFits(boost::filesystem::path path) const {
94  }
95 
96  void saveTile(ImageTile& /*tile*/) override {
97  assert(false);
98  }
99 
100  ImageTile::ImageType getType() const override {
101  return ImageTile::getTypeValue(T());
102  }
103 
104 private:
105  TypedSplineModelWrapper(const size_t* naxes, const size_t* gridCellSize, const size_t* nGrid, PIXTYPE* gridData){
106  m_spline_model = new SplineModel(naxes, gridCellSize, nGrid, gridData);
107  };
109 };
110 
111 } // end of namespace SourceXtractor
112 
113 #endif // TYPEDSPLINEMODELWRAPPER_H
114 
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
static ImageType getTypeValue(float)
Definition: ImageTile.h:97
static std::shared_ptr< ImageTile > create(ImageType image_type, int x, int y, int width, int height, std::shared_ptr< ImageSource > source=nullptr)
Definition: ImageTile.cpp:24
void gridToFits(boost::filesystem::path &fitsName, const bool overwrite=true)
PIXTYPE getValue(size_t x, size_t y)
std::string getRepr() const override
Human readable representation.
T getMedian() const
Returns the median of the spline.
std::shared_ptr< ImageTile > getImageTile(int x, int y, int width, int height) const override
ImageTile::ImageType getType() const override
void gridToFits(boost::filesystem::path path) const
TypedSplineModelWrapper(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)
int getHeight() const override
Returns the height of the image in pixels.
int getWidth() const override
Returns the width of the image in pixels.
static std::shared_ptr< TypedSplineModelWrapper< T > > create(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)
T getValue(int x, int y) const
Returns the value of the pixel with the coordinates (x,y)
Elements::Path::Item path