SourceXtractorPlusPlus  0.8
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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:
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
std::string getRepr() const override
Get a string identifying this image in a human readable manner.
int getWidth() const override
Returns the width of the image in pixels.
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
int getHeight() const override
Returns the height of the image in pixels.
static std::shared_ptr< ImageBase< T > > create(Args &&...args)
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
FunctionalImage(int width, int height, FunctorType functor)
STL class.
T target_type(T...args)
virtual ~FunctionalImage()=default
T getValue(int x, int y) const override
Returns the value of the pixel with the coordinates (x,y)