SourceXtractorPlusPlus  0.10
Please provide a description of the project.
InterpolatedImage.h
Go to the documentation of this file.
1 
17 /*
18  * InterpolatedImage.h
19  *
20  * Created on: Apr 18, 2018
21  * Author: mschefer
22  */
23 
24 #ifndef SEFRAMEWORK_SEFRAMEWORK_IMAGE_INTERPOLATEDIMAGE_H_
25 #define SEFRAMEWORK_SEFRAMEWORK_IMAGE_INTERPOLATEDIMAGE_H_
26 
28 
29 namespace SourceXtractor {
30 
31 template <typename T>
32 class InterpolatedImage : public ImageBase<T> {
33 protected:
34 
35  InterpolatedImage(std::shared_ptr<Image<T>> image, std::shared_ptr<Image<T>> variance_map, T variance_threshold, int max_gap)
36  : m_image(image), m_variance_map(variance_map), m_variance_threshold(variance_threshold), m_max_gap(max_gap) {}
37 
38 public:
39  virtual ~InterpolatedImage() = default;
40 
41  static std::shared_ptr<InterpolatedImage<T>> create(std::shared_ptr<Image<T>> image, std::shared_ptr<Image<T>> variance_map, T variance_threshold, int max_gap) {
42  return std::shared_ptr<InterpolatedImage<T>>(new InterpolatedImage<T>(image, variance_map, variance_threshold, max_gap));
43  }
44 
45  virtual std::string getRepr() const override {
46  return "InterpolatedImage(" + m_image->getRepr() + "," + m_variance_map->getRepr() + ")";
47  }
48 
50  virtual T getValue(int x, int y) const override {
51  if (isPixelGood(x, y)) {
52  return m_image->getValue(x, y);
53  }
54 
55  for (int i=1; i <= m_max_gap; i++) {
56  if (x-i >= 0 && isPixelGood(x-i, y)) {
57  return m_image->getValue(x-i, y);
58  }
59  if (y-i >= 0 && isPixelGood(x, y-i)) {
60  return m_image->getValue(x, y-i);
61  }
62  }
63 
64  // Couldn't interpolate, return what we have
65  return m_image->getValue(x, y);
66  }
67 
68  virtual int getWidth() const override {
69  return m_image->getWidth();
70  }
71 
72  virtual int getHeight() const override {
73  return m_image->getHeight();
74  }
75 
76 private:
77  bool isPixelGood(int x, int y) const {
78  return m_variance_map->getValue(x, y) < m_variance_threshold;
79  }
80 
84 
85  int m_max_gap;
86 };
87 
88 
89 }
90 
91 
92 #endif /* SEFRAMEWORK_SEFRAMEWORK_IMAGE_INTERPOLATEDIMAGE_H_ */
SourceXtractor::InterpolatedImage::getValue
virtual T getValue(int x, int y) const override
Returns the value of the pixel with the coordinates (x,y)
Definition: InterpolatedImage.h:50
ImageBase.h
SourceXtractor::InterpolatedImage::getHeight
virtual int getHeight() const override
Returns the height of the image in pixels.
Definition: InterpolatedImage.h:72
std::string
STL class.
std::shared_ptr
STL class.
SourceXtractor::InterpolatedImage::m_variance_map
std::shared_ptr< Image< T > > m_variance_map
Definition: InterpolatedImage.h:82
SourceXtractor::InterpolatedImage::isPixelGood
bool isPixelGood(int x, int y) const
Definition: InterpolatedImage.h:77
SourceXtractor::InterpolatedImage::m_variance_threshold
T m_variance_threshold
Definition: InterpolatedImage.h:83
SourceXtractor::InterpolatedImage::m_max_gap
int m_max_gap
Definition: InterpolatedImage.h:85
SourceXtractor::Image
Interface representing an image.
Definition: Image.h:43
SourceXtractor::InterpolatedImage::~InterpolatedImage
virtual ~InterpolatedImage()=default
SourceXtractor
Definition: Aperture.h:30
SourceXtractor::InterpolatedImage::InterpolatedImage
InterpolatedImage(std::shared_ptr< Image< T >> image, std::shared_ptr< Image< T >> variance_map, T variance_threshold, int max_gap)
Definition: InterpolatedImage.h:35
SourceXtractor::InterpolatedImage::m_image
std::shared_ptr< Image< T > > m_image
Definition: InterpolatedImage.h:81
SourceXtractor::InterpolatedImage::create
static std::shared_ptr< InterpolatedImage< T > > create(std::shared_ptr< Image< T >> image, std::shared_ptr< Image< T >> variance_map, T variance_threshold, int max_gap)
Definition: InterpolatedImage.h:41
SourceXtractor::InterpolatedImage
Definition: InterpolatedImage.h:32
x
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > x
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::InterpolatedImage::getRepr
virtual std::string getRepr() const override
Get a string identifying this image in a human readable manner.
Definition: InterpolatedImage.h:45
SourceXtractor::InterpolatedImage::getWidth
virtual int getWidth() const override
Returns the width of the image in pixels.
Definition: InterpolatedImage.h:68
y
std::shared_ptr< DependentParameter< std::shared_ptr< EngineParameter > > > y
Definition: MoffatModelFittingTask.cpp:93
SourceXtractor::ImageBase
Definition: ImageBase.h:35