SourceXtractorPlusPlus  0.11
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Frame.h
Go to the documentation of this file.
1 
17 /*
18  * Frame.h
19  *
20  * Created on: Mar 13, 2017
21  * Author: mschefer
22  */
23 
24 #ifndef _SEFRAMEWORK_FRAME_FRAME_H_
25 #define _SEFRAMEWORK_FRAME_FRAME_H_
26 
27 #include <algorithm>
28 
29 #include "SEUtils/Types.h"
32 
33 namespace SourceXtractor {
34 
35 template<typename T>
36 class Frame {
37 
38 public:
39  class ImageFilter {
40  public:
41  virtual ~ImageFilter() = default;
42  virtual std::shared_ptr<Image<T>> processImage(std::shared_ptr<Image<T>> image, std::shared_ptr<Image<T>> variance, T threshold) const = 0;
43  };
44 
45  Frame(std::shared_ptr<Image<T>> detection_image,
46  std::shared_ptr<WeightImage> variance_map,
47  WeightImage::PixelType variance_threshold,
48  std::shared_ptr<CoordinateSystem> coordinate_system,
49  SeFloat gain, SeFloat saturation, int interpolation_gap);
50 
51  // FIXME: this simplified version is used in unit tests, get rid of it
52  Frame(std::shared_ptr<Image<T>> detection_image,
53  std::shared_ptr<CoordinateSystem> coordinate_system = nullptr,
54  std::shared_ptr<WeightImage> variance_map = nullptr);
55 
56  //
57  // Methods to get the image in one form or another
58  //
59 
60  // Just the original image
62  return m_image;
63  }
64 
65  // Returns the image with bad pixels interpolated (if interpolation is active, otherwise returns original)
67 
68  // Get the image with the background subtracted
70 
71  // Get the image with a filter applied to the subtracted image
73 
74  // Get the filtered image with the detection threshold subtracted from it
76 
77  // Get the SNR image
79 
80  //
81  // Methods to get the image in one form or another
82  //
83 
85 
87 
89  return m_variance_map;
90  }
91 
92  //
93  // Methods to get frame metadata
94  //
95 
97  return m_coordinate_system;
98  }
99 
101  return m_variance_threshold;
102  }
103 
104  SeFloat getGain() const {
105  return m_gain;
106  }
107 
109  return m_saturation;
110  }
111 
113  return m_background_rms;
114  }
115 
117  // FIXME using the 0,0 pixel makes no sense
118  return sqrt(m_variance_map->getValue(0,0)) * m_detection_threshold;
119  }
120 
122 
124  return m_label;
125  }
126 
127  //
128  // Setters
129  //
130 
131  void setVarianceMap(std::shared_ptr<WeightImage> variance_map);
132 
134 
136 
137  void setDetectionThreshold(T detection_threshold);
138 
139  void setBackgroundLevel(T background_level);
140 
141  void setBackgroundLevel(std::shared_ptr<Image<T>> background_level_map, T background_rms);
142 
144 
145  void setLabel(const std::string &label);
146 
147 private:
148 
149  void applyFilter();
150 
154 
156 
160 
163 
164  int m_interpolation_gap; // max interpolation gap, 0 == no interpolation
165 
171 
173 };
174 
177 
178 }
179 
180 #endif /* _SEFRAMEWORK_FRAME_FRAME_H_ */
std::shared_ptr< Image< T > > getSnrImage() const
Definition: Frame.cpp:107
std::shared_ptr< Image< T > > getOriginalImage() const
Definition: Frame.h:61
std::shared_ptr< Image< T > > m_image
Definition: Frame.h:151
std::shared_ptr< Image< T > > getThresholdedImage() const
Definition: Frame.cpp:101
std::shared_ptr< WeightImage > getVarianceMap() const
Definition: Frame.cpp:113
std::shared_ptr< Image< T > > m_filtered_image
Definition: Frame.h:169
SeFloat m_saturation
Definition: Frame.h:158
std::shared_ptr< Image< T > > getBackgroundLevelMap() const
Definition: Frame.cpp:172
std::string getLabel() const
Definition: Frame.h:123
SeFloat32 SeFloat
Definition: Types.h:32
std::shared_ptr< Image< T > > m_interpolated_image
Definition: Frame.h:167
std::shared_ptr< WeightImage > getUnfilteredVarianceMap() const
Definition: Frame.cpp:122
std::shared_ptr< Image< T > > getDetectionThresholdMap() const
Definition: Frame.cpp:139
std::shared_ptr< WeightImage > m_variance_map
Definition: Frame.h:152
std::shared_ptr< Image< WeightImage::PixelType > > m_interpolated_variance
Definition: Frame.h:168
STL class.
virtual std::shared_ptr< Image< T > > processImage(std::shared_ptr< Image< T >> image, std::shared_ptr< Image< T >> variance, T threshold) const =0
SeFloat getGain() const
Definition: Frame.h:104
std::string m_label
Definition: Frame.h:172
std::shared_ptr< WeightImage > getOriginalVarianceMap() const
Definition: Frame.h:88
std::shared_ptr< Image< T > > m_background_level_map
Definition: Frame.h:153
std::shared_ptr< Image< T > > getFilteredImage() const
Definition: Frame.cpp:92
std::shared_ptr< CoordinateSystem > getCoordinateSystem() const
Definition: Frame.h:96
std::shared_ptr< Image< T > > getSubtractedImage() const
Definition: Frame.cpp:86
void setVarianceThreshold(WeightImage::PixelType threshold)
Definition: Frame.cpp:161
void setLabel(const std::string &label)
Definition: Frame.cpp:212
std::shared_ptr< ImageFilter > m_filter
Definition: Frame.h:166
std::shared_ptr< Image< T > > m_filtered_variance_map
Definition: Frame.h:170
SeFloat m_background_rms
Definition: Frame.h:159
void setVarianceMap(std::shared_ptr< WeightImage > variance_map)
Definition: Frame.cpp:150
Frame(std::shared_ptr< Image< T >> detection_image, std::shared_ptr< WeightImage > variance_map, WeightImage::PixelType variance_threshold, std::shared_ptr< CoordinateSystem > coordinate_system, SeFloat gain, SeFloat saturation, int interpolation_gap)
Definition: Frame.cpp:30
std::shared_ptr< CoordinateSystem > m_coordinate_system
Definition: Frame.h:155
void setDetectionThreshold(T detection_threshold)
Definition: Frame.cpp:184
T getDetectionThreshold() const
Definition: Frame.h:116
WeightImage::PixelType m_variance_threshold
Definition: Frame.h:162
Interface representing an image.
Definition: Image.h:43
T sqrt(T...args)
void setFilter(std::shared_ptr< ImageFilter > filter)
Definition: Frame.cpp:204
void setBackgroundLevel(T background_level)
Definition: Frame.cpp:190
std::shared_ptr< Image< T > > getInterpolatedImage() const
Definition: Frame.cpp:69
SeFloat getBackgroundMedianRms() const
Definition: Frame.h:112
SeFloat getSaturation() const
Definition: Frame.h:108
WeightImage::PixelType getVarianceThreshold() const
Definition: Frame.h:100