DistanceModelExponential.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 DISTANCEMODEL_EXP_H_
32 #define DISTANCEMODEL_EXP_H_
33 
34 
35 
36 #include <math.h>
37 
38 #include "DistanceModel.h"
39 
40 
41 namespace drain
42 {
43 
44 namespace image
45 {
46 
56 
57 public:
58 
59  DistanceModelExponential() : DistanceModel(__FUNCTION__, "Exponentially decreasing intensities. Set half-decay radii."){
60  setRadius(horzRadius.forward, vertRadius.forward);
61  };
62 
63  void setRadius(float horz, float vert = nan_f, float horzLeft = nan_f, float vertUp = nan_f);
64 
66  void setDecrement(float horz, float vert = nan_f, float horzRight = nan_f, float vertUp = nan_f);
67 
68  virtual
69  DistanceElement getElement(short dx, short dy, bool forward=true) const;
70 
71  // NEW
72  virtual inline
73  float decrease(float value, float coeff) const {
74  return value * coeff;
75  };
76 
77 protected:
78 
79  float radius2Dec(float r, float rDefault = -1.0) const;
80 
81  float checkDec(float d, float dDefault = 0.75) const;
82 
83 };
84 
85 DRAIN_TYPENAME(DistanceModelExponential);
86 
87 
88 }
89 }
90 
91 #endif
92 
93 
94 // Drain
Definition: DistanceModel.h:76
Definition: DistanceModelExponential.h:55
void setRadius(float horz, float vert=nan_f, float horzLeft=nan_f, float vertUp=nan_f)
Sets the geometry of the distance model.
Definition: DistanceModelExponential.cpp:54
void setDecrement(float horz, float vert=nan_f, float horzRight=nan_f, float vertUp=nan_f)
Definition: DistanceModelExponential.cpp:106
Base class for linear and exponential distances in rectangular pixel images.
Definition: DistanceModel.h:123
DistanceModel(const std::string &name, const std::string &description="")
Base class for digital distance models. Supports 4-, 8- and extended "chess knight" distance.
Definition: DistanceModel.h:254
Definition: DataSelector.cpp:1277