SourceXtractorPlusPlus  0.15
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ClippedImage.h
Go to the documentation of this file.
1 
18 #ifndef _SEFRAMEWORK_IMAGE_CLIPPEDIMAGE_H_
19 #define _SEFRAMEWORK_IMAGE_CLIPPEDIMAGE_H_
20 
22 
23 namespace SourceXtractor {
24 
30 template <typename T>
31 class ClippedImage: public Image<T> {
32 private:
33 
47  ClippedImage(std::shared_ptr<const Image<T>> img, int x, int y, int w, int h)
48  : m_img{img}, m_clip_x{x}, m_clip_y{y}, m_clip_w{w}, m_clip_h{h} {
49  assert(img->getWidth() - m_clip_x >= m_clip_w);
50  assert(img->getHeight() - m_clip_y >= m_clip_h);
51  }
52 
53 public:
54 
55  template <typename ...Args>
56  static std::shared_ptr<ClippedImage<T>> create(Args&& ...args) {
57  return std::shared_ptr<ClippedImage<T>>(new ClippedImage<T>(std::forward<Args>(args)...));
58  }
59 
60  std::string getRepr() const override {
61  return "Clipped(" + m_img->getRepr() + ")";
62  }
63 
64  int getWidth() const override {
65  return m_clip_w;
66  }
67 
68  int getHeight() const override {
69  return m_clip_h;
70  }
71 
72  std::shared_ptr<ImageChunk<T>> getChunk(int x, int y, int width, int height) const override {
73  return m_img->getChunk(x + m_clip_x, y + m_clip_y, width, height);
74  }
75 
76 private:
80 };
81 
82 } // end of namespace SourceXtractor
83 
84 #endif // _SEFRAMEWORK_IMAGE_CLIPPEDIMAGE_H_
ClippedImage(std::shared_ptr< const Image< T >> img, int x, int y, int w, int h)
Definition: ClippedImage.h:47
std::shared_ptr< const Image< T > > m_img
Definition: ClippedImage.h:77
static std::shared_ptr< ClippedImage< T > > create(Args &&...args)
Definition: ClippedImage.h:56
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
STL class.
std::string getRepr() const override
Get a string identifying this image in a human readable manner.
Definition: ClippedImage.h:60
std::shared_ptr< ImageChunk< T > > getChunk(int x, int y, int width, int height) const override
Definition: ClippedImage.h:72
int getHeight() const override
Returns the height of the image in pixels.
Definition: ClippedImage.h:68
Interface representing an image.
Definition: Image.h:43
int getWidth() const override
Returns the width of the image in pixels.
Definition: ClippedImage.h:64