SourceXtractorPlusPlus 0.21
SourceXtractor++, the next generation SExtractor
Loading...
Searching...
No Matches
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
27namespace SourceXtractor {
28
35template <typename T, typename P>
36class ProcessedImage : public Image<T> {
37
38protected:
39
42 assert(m_image_a->getWidth() == m_image_b->getWidth());
43 assert(m_image_a->getHeight() == m_image_b->getHeight());
44 };
45
46public:
47
51 virtual ~ProcessedImage() = default;
52
57
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 }
86 }
87
88private:
91
92}; /* End of ProcessedImage class */
93
94
95template<typename T>
97{
98 static T process(const T& a, const T& b) { return a - b; }
99};
100
101template<typename T>
103
104template<typename T>
106{
107 static T process(const T& a, const T& b) { return a * b; }
108};
109
110template<typename T>
112
113template<typename T>
115{
116 static T process(const T& a, const T& b) { return a / sqrt(b); }
117};
118
119template<typename T>
121
122} /* namespace SourceXtractor */
123
124
125
126
127#endif /* _SEFRAMEWORK_IMAGE_PROCESSEDIMAGE_H_ */
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Interface representing an image.
Definition Image.h:44
Processes two images to create a third combining them by using any function.
ProcessedImage(std::shared_ptr< const Image< T > > image_a, std::shared_ptr< const Image< T > > image_b)
virtual ~ProcessedImage()=default
Destructor.
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T > > image_a, T value)
std::shared_ptr< const Image< T > > m_image_a
std::string getRepr() const override
Get a string identifying this image in a human readable manner.
std::shared_ptr< const Image< T > > m_image_b
int getHeight() const override
Returns the height of the image in pixels.
std::shared_ptr< ImageChunk< T > > getChunk(int x, int y, int width, int height) const override
static std::shared_ptr< ProcessedImage< T, P > > create(std::shared_ptr< const Image< T > > image_a, std::shared_ptr< const Image< T > > image_b)
int getWidth() const override
Returns the width of the image in pixels.
static std::shared_ptr< UniversalImageChunk< T > > create(Args &&... args)
Definition ImageChunk.h:144
T move(T... args)
T sqrt(T... args)
static T process(const T &a, const T &b)
static T process(const T &a, const T &b)
static T process(const T &a, const T &b)