SourceXtractorPlusPlus  0.11
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 
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_ */
SourceXtractor::ConstantImage
Definition: ConstantImage.h:33
SourceXtractor::ProcessedImage::m_image_b
std::shared_ptr< const Image< T > > m_image_b
Definition: ProcessedImage.h:95
ImageBase.h
std::string
STL class.
std::shared_ptr
STL class.
SourceXtractor::SubtractOperation
Definition: ProcessedImage.h:102
std::move
T move(T... args)
ConstantImage.h
SourceXtractor::SubtractOperation::process
static T process(const T &a, const T &b)
Definition: ProcessedImage.h:103
SourceXtractor::MultiplyOperation::process
static T process(const T &a, const T &b)
Definition: ProcessedImage.h:112
SourceXtractor::ProcessedImage
Processes two images to create a third combining them by using any function.
Definition: ProcessedImage.h:37
SourceXtractor::Image
Interface representing an image.
Definition: Image.h:43
VectorImage.h
SourceXtractor::SnrOperation
Definition: ProcessedImage.h:120
std::sqrt
T sqrt(T... args)
SourceXtractor::ProcessedImage::getHeight
int getHeight() const override
Returns the height of the image in pixels.
Definition: ProcessedImage.h:77
SourceXtractor::ProcessedImage::getValue
T getValue(int x, int y) const override
Returns the value of the pixel with the coordinates (x,y)
Definition: ProcessedImage.h:69
SourceXtractor::ProcessedImage::~ProcessedImage
virtual ~ProcessedImage()=default
Destructor.
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::MultiplyOperation
Definition: ProcessedImage.h:111
SourceXtractor::VectorImage::create
static std::shared_ptr< VectorImage< T > > create(Args &&... args)
Definition: VectorImage.h:89
SourceXtractor::ProcessedImage::getChunk
std::shared_ptr< ImageChunk< T > > getChunk(int x, int y, int width, int height) const override
Definition: ProcessedImage.h:81
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:41
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:54
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::UniversalImageChunk::create
static std::shared_ptr< UniversalImageChunk< T > > create(Args &&... args)
Definition: ImageChunk.h:132
SourceXtractor::ProcessedImage::m_image_a
std::shared_ptr< const Image< T > > m_image_a
Definition: ProcessedImage.h:94
SourceXtractor::ProcessedImage::getRepr
std::string getRepr() const override
Get a string identifying this image in a human readable manner.
Definition: ProcessedImage.h:64
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::ProcessedImage::create
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T >> image_a, T value)
Definition: ProcessedImage.h:59
SourceXtractor::ProcessedImage::getWidth
int getWidth() const override
Returns the width of the image in pixels.
Definition: ProcessedImage.h:73
SourceXtractor::ImageBase
Definition: ImageBase.h:35
SourceXtractor::SnrOperation::process
static T process(const T &a, const T &b)
Definition: ProcessedImage.h:121