SourceXtractorPlusPlus  0.14
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 {
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> getImageTile(int x, int y, int width, int height) const override {
80  auto tile = ImageTile::create(ImageTile::getTypeValue(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& /*tile*/) override {
98  assert(false);
99  }
100 
101  ImageTile::ImageType getType() const override {
102  return ImageTile::getTypeValue(T());
103  }
104 
105 private:
106  TypedSplineModelWrapper(const size_t* naxes, const size_t* gridCellSize, const size_t* nGrid, PIXTYPE* gridData){
107  m_spline_model = new SplineModel(naxes, gridCellSize, nGrid, gridData);
108  };
110 };
111 
112 } // end of namespace SourceXtractor
113 
114 #endif // TYPEDSPLINEMODELWRAPPER_H
115 
static std::shared_ptr< TypedSplineModelWrapper< T > > create(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)
std::shared_ptr< ImageTile > getImageTile(int x, int y, int width, int height) const override
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
T getMedian() const
Returns the median of the spline.
int getWidth() const override
Returns the width of the image in pixels.
void gridToFits(boost::filesystem::path path) const
ImageTile::ImageType getType() const override
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
STL class.
std::string getRepr() const override
Human readable representation.
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)
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
int getHeight() const override
Returns the height of the image in pixels.
Elements::Path::Item path
TypedSplineModelWrapper(const size_t *naxes, const size_t *gridCellSize, const size_t *nGrid, PIXTYPE *gridData)
static ImageType getTypeValue(float)
Definition: ImageTile.h:99