SourceXtractorPlusPlus  0.15
Please provide a description of the project.
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_ */
SourceXtractor::ConstantImage
Definition: ConstantImage.h:33
SourceXtractor::ProcessedImage::m_image_b
std::shared_ptr< const Image< T > > m_image_b
Definition: ProcessedImage.h:90
std::string
STL class.
std::shared_ptr
STL class.
SourceXtractor::SubtractOperation
Definition: ProcessedImage.h:97
std::move
T move(T... args)
ConstantImage.h
SourceXtractor::SubtractOperation::process
static T process(const T &a, const T &b)
Definition: ProcessedImage.h:98
SourceXtractor::MultiplyOperation::process
static T process(const T &a, const T &b)
Definition: ProcessedImage.h:107
std::vector
STL class.
SourceXtractor::ProcessedImage
Processes two images to create a third combining them by using any function.
Definition: ProcessedImage.h:36
SourceXtractor::Image
Interface representing an image.
Definition: Image.h:43
VectorImage.h
SourceXtractor::SnrOperation
Definition: ProcessedImage.h:115
std::sqrt
T sqrt(T... args)
SourceXtractor::ProcessedImage::getHeight
int getHeight() const override
Returns the height of the image in pixels.
Definition: ProcessedImage.h:71
SourceXtractor::ProcessedImage::~ProcessedImage
virtual ~ProcessedImage()=default
Destructor.
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::MultiplyOperation
Definition: ProcessedImage.h:106
SourceXtractor::ProcessedImage::getChunk
std::shared_ptr< ImageChunk< T > > getChunk(int x, int y, int width, int height) const override
Definition: ProcessedImage.h:75
Image.h
SourceXtractor::ProcessedImage::ProcessedImage
ProcessedImage(std::shared_ptr< const Image< T >> image_a, std::shared_ptr< const Image< T >> image_b)
Definition: ProcessedImage.h:40
SourceXtractor::ProcessedImage::create
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T >> image_a, std::shared_ptr< const Image< T >> image_b)
Definition: ProcessedImage.h:53
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:94
SourceXtractor::UniversalImageChunk::create
static std::shared_ptr< UniversalImageChunk< T > > create(Args &&... args)
Definition: ImageChunk.h:142
SourceXtractor::ProcessedImage::m_image_a
std::shared_ptr< const Image< T > > m_image_a
Definition: ProcessedImage.h:89
SourceXtractor::ProcessedImage::getRepr
std::string getRepr() const override
Get a string identifying this image in a human readable manner.
Definition: ProcessedImage.h:63
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:94
SourceXtractor::ProcessedImage::create
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T >> image_a, T value)
Definition: ProcessedImage.h:58
SourceXtractor::ProcessedImage::getWidth
int getWidth() const override
Returns the width of the image in pixels.
Definition: ProcessedImage.h:67
SourceXtractor::SnrOperation::process
static T process(const T &a, const T &b)
Definition: ProcessedImage.h:116