AccumulationArray.h
1 /*
2 
3 MIT License
4 
5 Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6 
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13 
14 The above copyright notice and this permission notice shall be included in all
15 copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 SOFTWARE.
24 
25 */
26 /*
27 Part of Rack development has been done in the BALTRAD projects part-financed
28 by the European Union (European Regional Development Fund and European
29 Neighbourhood Partnership Instrument, Baltic Sea Region Programme 2007-2013)
30 */
31 #ifndef ACCUMULATIONARRAY_H_
32 #define ACCUMULATIONARRAY_H_
33 
34 #include <limits>
35 #include <math.h>
36 
37 #include <stdexcept>
38 
39 //#include "drain/util/Data.h"
40 //#include "drain/util/Variable.h"
41 //#include "drain/util/DataScaling.h"
42 
43 #include "drain/util/Point.h"
44 #include "ImageT.h"
45 //#include "Coordinates.h"
46 #include "CoordinateHandler.h"
47 
48 //#include "AccumulationRules.h"
49 
50 #include "AccumulationConverter.h"
51 
52 
53 // TODO: image/
57 namespace drain
58 {
59 
60 namespace image
61 {
62 
63 
64 
65 class AccumulationMethod;
66 /*
67 class AverageRule;
68 class WeightedAverageRule;
69 */
70 
71 
72 
74 
112 {
113 public:
114 
115  friend class AccumulationMethod;
116 
118  AccumulationArray(size_t width = 0, size_t height = 0){ // : debug(false) {
119  setGeometry(width, height);
120  };
121 
122  inline
123  AccumulationArray(const AccumulationArray & accArray){ // : debug(false) {
124  setGeometry(accArray.getGeometry());
125  };
126 
128  virtual ~AccumulationArray(){};
129 
131  virtual
132  void setGeometry(size_t width, size_t height);
133 
135  inline
136  void setGeometry(const AreaGeometry & geometry){
137  setGeometry(geometry.getWidth(), geometry.getHeight());
138  }
139 
140 
141  inline
142  const AreaGeometry & getGeometry() const {
143  return geometry;
144  }
145 
147  void clear();
148 
150  inline
151  void reset(){
152  setGeometry(0, 0);
153  };
154 
155 
157  inline
158  unsigned int getWidth() const { return geometry.width; };
159 
161  inline
162  unsigned int getHeight() const { return geometry.height; };
163 
164  inline
165  const CoordinateHandler2D & getCoordinateHandler() const {
166  return coordinateHandler;
167  };
168 
169  //bool debug;
170 
171  inline
172  size_t address(const size_t &i, const size_t &j) const {
173  return data.address(i,j);
174  };
175 
176 //protected:
177 
180 
183 
186 
188  // actual data \f$ sum w_i^r x_i^{2p} \f$
190 
191 
192 
193 protected:
194 
195  AreaGeometry geometry;
196 
197  CoordinateHandler2D coordinateHandler;
198 
199 };
200 
201 std::ostream & operator<<(std::ostream &ostr, const AccumulationArray &cumulator);
202 
203 
204 }
205 
206 }
207 
208 #endif /* Cumulator_H_ */
209 
210 // Drain
General-purpose image compositing.
Definition: AccumulationArray.h:112
AccumulationArray(size_t width=0, size_t height=0)
Default constructor. The channels are DATA, COUNT, WEIGHT, WEIGHT2.
Definition: AccumulationArray.h:118
ImageT< double > data
Accumulation array for actual data: , or generally .
Definition: AccumulationArray.h:174
unsigned int getHeight() const
Returns the height of the accumulation array.
Definition: AccumulationArray.h:162
virtual ~AccumulationArray()
Destructor.
Definition: AccumulationArray.h:128
virtual void setGeometry(size_t width, size_t height)
Changes the geometry of all the layers.
Definition: AccumulationArray.cpp:47
ImageT< double > data2
Accumulation array for auxiliary data; typically for std.deviation or difference (in Overwrite)
Definition: AccumulationArray.h:189
void setGeometry(const AreaGeometry &geometry)
Changes the geometry of all the layers.
Definition: AccumulationArray.h:136
ImageT< unsigned int > count
Accumulation array ( in )
Definition: AccumulationArray.h:185
unsigned int getWidth() const
Returns the width of the accumulation array.
Definition: AccumulationArray.h:158
void clear()
Resets the accumulation array values to undetectValue. Does not change the geometry.
Definition: AccumulationArray.cpp:63
void reset()
Collapses the accumulation geometries to zero area.
Definition: AccumulationArray.h:151
ImageT< double > weight
Accumulation array for weights ( )
Definition: AccumulationArray.h:182
Function for accumulating data: maximum, average, weighted average etc.
Definition: AccumulationMethods.h:64
Definition: CoordinateHandler.h:62
size_t address(size_t i) const
Computes the index location from image coordinates. Does not involve bit resolution.
Definition: ImageFrame.h:148
Definition: DataSelector.cpp:1277