SourceXtractorPlusPlus  0.10
Please provide a description of the project.
FunctionalImage.h
Go to the documentation of this file.
1 
17 /*
18  * @file SEFramework/Image/FunctionalImage.h
19  * @date 27/03/19
20  * @author Alejandro Alvarez Ayllon
21  */
22 
23 #ifndef _SEFRAMEWORK_IMAGE_FUNCTIONALIMAGE_H
24 #define _SEFRAMEWORK_IMAGE_FUNCTIONALIMAGE_H
25 
27 
28 namespace SourceXtractor {
29 
30 template<typename T>
31 class FunctionalImage : public ImageBase<T> {
32 public:
33  using FunctorType = std::function<T(int x, int y)>;
34 
35 protected:
36  FunctionalImage(int width, int height, FunctorType functor)
37  : m_width{width}, m_height{height}, m_functor{functor} {
38  }
39 
40 public:
41  virtual ~FunctionalImage() = default;
42 
43  template<typename ...Args>
44  static std::shared_ptr<ImageBase<T>> create(Args&& ... args) {
45  return std::shared_ptr<FunctionalImage<T>>(new FunctionalImage{std::forward<Args>(args)...});
46  }
47 
48  std::string getRepr() const override {
49  return "FunctionalImage<" + std::string(m_functor.target_type().name()) + ">";
50  }
51 
52  T getValue(int x, int y) const override {
53  return m_functor(x, y);
54  }
55 
56  int getWidth() const override {
57  return m_width;
58  }
59 
60  int getHeight() const override {
61  return m_height;
62  }
63 
64 private:
67 };
68 
69 } // end SourceXtractor
70 
71 #endif // _SEFRAMEWORK_IMAGE_FUNCTIONALIMAGE_H
SourceXtractor::FunctionalImage
Definition: FunctionalImage.h:31
ImageBase.h
std::string
STL class.
std::shared_ptr
STL class.
SourceXtractor::FunctionalImage::getValue
T getValue(int x, int y) const override
Returns the value of the pixel with the coordinates (x,y)
Definition: FunctionalImage.h:52
SourceXtractor::FunctionalImage::getRepr
std::string getRepr() const override
Get a string identifying this image in a human readable manner.
Definition: FunctionalImage.h:48
SourceXtractor::FunctionalImage::m_width
int m_width
Definition: FunctionalImage.h:65
SourceXtractor::FunctionalImage::getHeight
int getHeight() const override
Returns the height of the image in pixels.
Definition: FunctionalImage.h:60
std::function< T(int x, int y)>
SourceXtractor::FunctionalImage::m_height
int m_height
Definition: FunctionalImage.h:65
std::function::target_type
T target_type(T... args)
SourceXtractor::FunctionalImage::~FunctionalImage
virtual ~FunctionalImage()=default
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::FunctionalImage::m_functor
FunctorType m_functor
Definition: FunctionalImage.h:66
SourceXtractor::FunctionalImage::getWidth
int getWidth() const override
Returns the width of the image in pixels.
Definition: FunctionalImage.h:56
SourceXtractor::FunctionalImage::FunctionalImage
FunctionalImage(int width, int height, FunctorType functor)
Definition: FunctionalImage.h:36
SourceXtractor::FunctionalImage::create
static std::shared_ptr< ImageBase< T > > create(Args &&... args)
Definition: FunctionalImage.h:44
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:93
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::ImageBase
Definition: ImageBase.h:35