SourceXtractorPlusPlus  0.15
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProcessedImage.h
Go to the documentation of this file.
1 
18 #ifndef _SEFRAMEWORK_IMAGE_PROCESSEDIMAGE_H_
19 #define _SEFRAMEWORK_IMAGE_PROCESSEDIMAGE_H_
20 
21 #include <memory>
22 
26 
27 namespace SourceXtractor {
28 
35 template <typename T, typename P>
36 class ProcessedImage : public Image<T> {
37 
38 protected:
39 
41  : m_image_a(image_a), m_image_b(image_b) {
42  assert(m_image_a->getWidth() == m_image_b->getWidth());
43  assert(m_image_a->getHeight() == m_image_b->getHeight());
44  };
45 
46 public:
47 
51  virtual ~ProcessedImage() = default;
52 
54  std::shared_ptr<const Image<T>> image_a, std::shared_ptr<const Image<T>> image_b) {
55  return std::shared_ptr<ProcessedImage<T, P>>(new ProcessedImage<T, P>(image_a, image_b));
56  }
57 
60  image_a, ConstantImage<T>::create(image_a->getWidth(), image_a->getHeight(), value)));
61  }
62 
63  std::string getRepr() const override {
64  return "ProcessedImage(" + m_image_a->getRepr() + "," + m_image_b->getRepr() + ")";
65  }
66 
67  int getWidth() const override {
68  return m_image_a->getWidth();
69  }
70 
71  int getHeight() const override {
72  return m_image_a->getHeight();
73  }
74 
75  std::shared_ptr<ImageChunk<T>> getChunk(int x, int y, int width, int height) const override {
76  std::vector<T> new_chunk_data(width * height);
77  auto a_chunk = m_image_a->getChunk(x, y, width, height);
78  auto b_chunk = m_image_b->getChunk(x, y, width, height);
79  for (int iy = 0; iy < height; ++iy) {
80  for (int ix = 0; ix < width; ++ix) {
81  new_chunk_data[ix + iy * width] = P::process(a_chunk->getValue(ix, iy),
82  b_chunk->getValue(ix, iy));
83  }
84  }
85  return UniversalImageChunk<T>::create(std::move(new_chunk_data), width, height);
86  }
87 
88 private:
91 
92 }; /* End of ProcessedImage class */
93 
94 
95 template<typename T>
97 {
98  static T process(const T& a, const T& b) { return a - b; }
99 };
100 
101 template<typename T>
103 
104 template<typename T>
106 {
107  static T process(const T& a, const T& b) { return a * b; }
108 };
109 
110 template<typename T>
112 
113 template<typename T>
115 {
116  static T process(const T& a, const T& b) { return a / sqrt(b); }
117 };
118 
119 template<typename T>
121 
122 } /* namespace SourceXtractor */
123 
124 
125 
126 
127 #endif /* _SEFRAMEWORK_IMAGE_PROCESSEDIMAGE_H_ */
std::string getRepr() const override
Get a string identifying this image in a human readable manner.
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< const Image< T > > m_image_a
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T >> image_a, T value)
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
int getHeight() const override
Returns the height of the image in pixels.
STL class.
std::shared_ptr< ImageChunk< T > > getChunk(int x, int y, int width, int height) const override
ProcessedImage(std::shared_ptr< const Image< T >> image_a, std::shared_ptr< const Image< T >> image_b)
static std::shared_ptr< UniversalImageChunk< T > > create(Args &&...args)
Definition: ImageChunk.h:142
static T process(const T &a, const T &b)
T move(T...args)
STL class.
static T process(const T &a, const T &b)
static T process(const T &a, const T &b)
std::shared_ptr< const Image< T > > m_image_b
int getWidth() const override
Returns the width of the image in pixels.
static std::shared_ptr< ConstantImage< T > > create(int width, int height, T constant_value)
Definition: ConstantImage.h:42
Interface representing an image.
Definition: Image.h:43
virtual ~ProcessedImage()=default
Destructor.
T sqrt(T...args)
Processes two images to create a third combining them by using any function.
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T >> image_a, std::shared_ptr< const Image< T >> image_b)