SourceXtractorPlusPlus  0.13
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:
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 final {
49  return "FunctionalImage<" + std::string(m_functor.target_type().name()) + ">";
50  }
51 
52  T getValue(int x, int y) const final {
53  return m_functor(x, y);
54  }
55 
56  int getWidth() const final {
57  return m_width;
58  }
59 
60  int getHeight() const final {
61  return m_height;
62  }
63 
64  std::shared_ptr<ImageChunk<T>> getChunk(int x, int y, int width, int height) const final {
65  std::vector<T> data(width * height);
66  for (int iy = 0; iy < height; ++iy) {
67  for (int ix = 0; ix < width; ++ix) {
68  data[ix + iy * width] = m_functor(x + ix, y + iy);
69  }
70  }
71  return UniversalImageChunk<T>::create(std::move(data), width, height);
72  }
73 
74 private:
77 };
78 
79 } // end SourceXtractor
80 
81 #endif // _SEFRAMEWORK_IMAGE_FUNCTIONALIMAGE_H
int getWidth() const final
Returns the width of the image in pixels.
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< ImageChunk< T > > getChunk(int x, int y, int width, int height) const final
int getHeight() const final
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.
static std::shared_ptr< UniversalImageChunk< T > > create(Args &&...args)
Definition: ImageChunk.h:132
T move(T...args)
T getValue(int x, int y) const final
Returns the value of the pixel with the coordinates (x,y)
T target_type(T...args)
virtual ~FunctionalImage()=default
STL class.
std::string getRepr() const final
Get a string identifying this image in a human readable manner.