GapFillOp.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 
32 #ifndef GapFillerOP_H_
33 #define GapFillerOP_H_
34 
35 #include <drain/image/ImageFile.h>
36 #include "drain/util/Fuzzy.h"
37 #include "drain/image/Intensity.h"
38 //#include "drain/image/MathOpPack.h"
39 #include "radar/Geometry.h"
40 #include "RemoverOp.h"
41 
42 
43 
44 
45 
46 namespace rack {
47 
48 //using namespace drain::image;
49 //using namespace hi5;
50 
52 
55 class GapFillOpBase: public RemoverOp {
56 
57 public:
58 
59 
60  int widthM;
61  float heightD;
62 
63  // Originally for GapFillOpRec, but for combined op...
64  int loops;
65  double expansionCoeff;
66 
67 protected:
68 
69  // "Removes detected anomalies by overriding low-quality pixels with neighboring high-quality pixels."
70 
71  GapFillOpBase(const std::string &name, const std::string &description) :
72  RemoverOp(name, description){
73  dataSelector.setQuantities("^DBZH$");
74  };
75 
76 
77  virtual
78  void processData(const Data<PolarSrc> & srcData, Data<PolarDst> & dstData) const {
79  throw std::runtime_error(name +"::"+__FUNCTION__+ " not implemented");
80  };
81 
82 
83 
84 };
85 
86 
88 
91 class GapFillOp : public GapFillOpBase {
92 
93 public:
94 
99  GapFillOp(int width = 1500, float height = 5.0) :
100  GapFillOpBase(__FUNCTION__,"Removes low-quality data with gap fill based on distance transformation.") {
101  parameters.link("width", this->widthM = width, "meters");
102  parameters.link("height", this->heightD = height, "degrees");
103  //parameters.link("loops", this->loops = 0, "N");
104  //parameters.link("expansionCoeff", this->expansionCoeff = 1, "window extension(1..2)");
105  parameters.link("qualityThreshold", this->qualityThreshold = 0.1, "0.0...1.0");
106  };
107 
108 
109 protected:
110 
111  // virtual void processData(const Data<PolarSrc> & srcData, Data<PolarDst> & dstData) const;
112 
113  virtual
114  void processData(const PlainData<PolarSrc> & srcData, const PlainData<PolarSrc> & srcQuality,
115  PlainData<PolarDst> & dstData, PlainData<PolarDst> & dstQIND) const;
116 
117  double qualityThreshold;
118 
119 };
120 
121 
123 class GapFillRecOp : public GapFillOpBase {
124 
125 public:
126 
127  //"width=1500m,height=5deg,loops=3,decay=0.9"
128  GapFillRecOp(int width=1500, float height=5.0, int loops=3) : //, float decay=0.9) :
129  GapFillOpBase(__FUNCTION__, "Recursive, 'splinic' gap filler.") {
130  parameters.link("width", this->widthM = width, "meters");
131  parameters.link("height",this->heightD = height, "degrees");
132  parameters.link("loops", this->loops = loops, "N");
133  //link("decay", this->decay, decay, "0..1");
134  //initialize();
135  };
136 
137  //int loops;
138  //float decay;
139 
140 protected:
141 
142  //virtualvoid processData(const Data<PolarSrc> & srcData, Data<PolarDst> & dstData) const;
143 
144  virtual
145  void processData(const PlainData<PolarSrc> & srcData, const PlainData<PolarSrc> & srcQuality,
146  PlainData<PolarDst> & dstData, PlainData<PolarDst> & dstQIND) const;
147 
148 };
149 
150 
151 
152 } // rack::
153 
154 #endif /* GAPFILLOP_H_ */
155 
Data structure consisting of plain data and an optional quality data.
Definition: Data.h:1144
The base class for operators removing detected anomalies by overriding low-quality pixels with neighb...
Definition: GapFillOp.h:55
virtual void processData(const Data< PolarSrc > &srcData, Data< PolarDst > &dstData) const
Cleaning a the data array of one quantity (measurement parameter). Called by processDataSet.
Definition: GapFillOp.h:78
A simple gap filler based on distance transformation.
Definition: GapFillOp.h:91
virtual void processData(const PlainData< PolarSrc > &srcData, const PlainData< PolarSrc > &srcQuality, PlainData< PolarDst > &dstData, PlainData< PolarDst > &dstQIND) const
TODO: move to data tools etc?
Definition: GapFillOp.cpp:62
GapFillOp(int width=1500, float height=5.0)
Definition: GapFillOp.h:99
Recursive, 'splinic' gap filler based on fast averaging.
Definition: GapFillOp.h:123
Essential class for storing radar data.
Definition: Data.h:302
The simplest possible anomaly removal operator and the base class for more complex ones.
Definition: RemoverOp.h:53
RemoverOp(double threshold=0.5)
Definition: RemoverOp.h:61
Definition: DataSelector.cpp:44