SourceXtractorPlusPlus  0.8
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 
27 
28 namespace SourceXtractor {
29 
36 template <typename T, typename P>
37 class ProcessedImage : public ImageBase<T> {
38 
39 protected:
40 
42  : m_image_a(image_a), m_image_b(image_b) {
43  assert(m_image_a->getWidth() == m_image_b->getWidth());
44  assert(m_image_a->getHeight() == m_image_b->getHeight());
45  };
46 
47 public:
48 
52  virtual ~ProcessedImage() = default;
53 
55  std::shared_ptr<const Image<T>> image_a, std::shared_ptr<const Image<T>> image_b) {
56  return std::shared_ptr<ProcessedImage<T, P>>(new ProcessedImage<T, P>(image_a, image_b));
57  }
58 
61  image_a, ConstantImage<T>::create(image_a->getWidth(), image_a->getHeight(), value)));
62  }
63 
64  std::string getRepr() const override {
65  return "ProcessedImage(" + m_image_a->getRepr() + "," + m_image_b->getRepr() + ")";
66  }
67 
68  using Image<T>::getValue;
69  T getValue(int x, int y) const override {
70  return P::process(m_image_a->getValue(x, y), m_image_b->getValue(x, y));
71  }
72 
73  int getWidth() const override {
74  return m_image_a->getWidth();
75  }
76 
77  int getHeight() const override {
78  return m_image_a->getHeight();
79  }
80 
81  std::shared_ptr<ImageChunk<T>> getChunk(int x, int y, int width, int height) const override {
82  auto new_chunk_data = VectorImage<T>::create(width, height);
83  auto a_chunk = m_image_a->getChunk(x, y, width, height);
84  auto b_chunk = m_image_b->getChunk(x, y, width, height);
85  for (int iy = 0; iy < height; ++iy) {
86  for (int ix = 0; ix < width; ++ix) {
87  new_chunk_data->at(ix, iy) = P::process(a_chunk->getValue(ix,iy), b_chunk->getValue(ix,iy));
88  }
89  }
90  return UniversalImageChunk<T>::create(std::move(new_chunk_data->getData()), width, height);
91  }
92 
93 private:
96 
97 }; /* End of ProcessedImage class */
98 
99 
100 template<typename T>
102 {
103  static T process(const T& a, const T& b) { return a - b; }
104 };
105 
106 template<typename T>
108 
109 template<typename T>
111 {
112  static T process(const T& a, const T& b) { return a * b; }
113 };
114 
115 template<typename T>
117 
118 template<typename T>
120 {
121  static T process(const T& a, const T& b) { return a / sqrt(b); }
122 };
123 
124 template<typename T>
126 
127 } /* namespace SourceXtractor */
128 
129 
130 
131 
132 #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
static std::shared_ptr< VectorImage< T > > create(Args &&...args)
Definition: VectorImage.h:89
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:118
static T process(const T &a, const T &b)
T getValue(int x, int y) const override
Returns the value of the pixel with the coordinates (x,y)
T move(T...args)
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)