SourceXtractorPlusPlus  0.8
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  // FIXME using the 0,0 pixel makes no sense
114  return sqrt(m_variance_map->getValue(0,0)) * m_detection_threshold;
115  }
116 
118 
120  return m_label;
121  }
122 
123  //
124  // Setters
125  //
126 
127  void setVarianceMap(std::shared_ptr<WeightImage> variance_map);
128 
130 
132 
133  void setDetectionThreshold(T detection_threshold);
134 
135  void setBackgroundLevel(T background_level);
136 
137  void setBackgroundLevel(std::shared_ptr<Image<T>> background_level_map);
138 
140 
141  void setLabel(const std::string &label);
142 
143 private:
144 
145  void applyFilter();
146 
150 
152 
155 
158 
159  int m_interpolation_gap; // max interpolation gap, 0 == no interpolation
160 
166 
168 };
169 
172 
173 }
174 
175 #endif /* _SEFRAMEWORK_FRAME_FRAME_H_ */
std::shared_ptr< Image< T > > getSnrImage() const
Definition: Frame.cpp:105
std::shared_ptr< Image< T > > getOriginalImage() const
Definition: Frame.h:61
std::shared_ptr< Image< T > > m_image
Definition: Frame.h:147
std::shared_ptr< Image< T > > getThresholdedImage() const
Definition: Frame.cpp:99
std::shared_ptr< WeightImage > getVarianceMap() const
Definition: Frame.cpp:111
std::shared_ptr< Image< T > > m_filtered_image
Definition: Frame.h:164
SeFloat m_saturation
Definition: Frame.h:154
std::shared_ptr< Image< T > > getBackgroundLevelMap() const
Definition: Frame.cpp:170
std::string getLabel() const
Definition: Frame.h:119
SeFloat32 SeFloat
Definition: Types.h:32
std::shared_ptr< Image< T > > m_interpolated_image
Definition: Frame.h:162
std::shared_ptr< WeightImage > getUnfilteredVarianceMap() const
Definition: Frame.cpp:120
std::shared_ptr< Image< T > > getDetectionThresholdMap() const
Definition: Frame.cpp:137
std::shared_ptr< WeightImage > m_variance_map
Definition: Frame.h:148
std::shared_ptr< Image< WeightImage::PixelType > > m_interpolated_variance
Definition: Frame.h:163
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:167
std::shared_ptr< WeightImage > getOriginalVarianceMap() const
Definition: Frame.h:88
std::shared_ptr< Image< T > > m_background_level_map
Definition: Frame.h:149
std::shared_ptr< Image< T > > getFilteredImage() const
Definition: Frame.cpp:90
std::shared_ptr< CoordinateSystem > getCoordinateSystem() const
Definition: Frame.h:96
std::shared_ptr< Image< T > > getSubtractedImage() const
Definition: Frame.cpp:84
void setVarianceThreshold(WeightImage::PixelType threshold)
Definition: Frame.cpp:159
void setLabel(const std::string &label)
Definition: Frame.cpp:209
std::shared_ptr< ImageFilter > m_filter
Definition: Frame.h:161
std::shared_ptr< Image< T > > m_filtered_variance_map
Definition: Frame.h:165
void setVarianceMap(std::shared_ptr< WeightImage > variance_map)
Definition: Frame.cpp:148
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:151
void setDetectionThreshold(T detection_threshold)
Definition: Frame.cpp:182
T getDetectionThreshold() const
Definition: Frame.h:112
WeightImage::PixelType m_variance_threshold
Definition: Frame.h:157
Interface representing an image.
Definition: Image.h:43
T sqrt(T...args)
void setFilter(std::shared_ptr< ImageFilter > filter)
Definition: Frame.cpp:201
void setBackgroundLevel(T background_level)
Definition: Frame.cpp:188
std::shared_ptr< Image< T > > getInterpolatedImage() const
Definition: Frame.cpp:67
SeFloat getSaturation() const
Definition: Frame.h:108
WeightImage::PixelType getVarianceThreshold() const
Definition: Frame.h:100