DistanceModelLinear.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_LIN_H_
32 #define DISTANCEMODEL_LIN_H_
33 
34 
35 
36 #include <math.h>
37 
38 #include <drain/Type.h>
39 
40 #include "DistanceModel.h"
41 
42 
43 namespace drain
44 {
45 
46 namespace image
47 {
48 
49 
51 {
52 
53 public:
54 
55  DistanceModelLinear() : DistanceModel(__FUNCTION__, "Linearly decreasing intensities - applies decrements."){
56  //setRadius(widths[0], heights[0]);
57  };
58 
60  void setRadius(float horz, float vert = nan_f, float horzLeft = nan_f, float vertUp = nan_f);
61 
63  void setDecrement(float horz, float vert = nan_f, float horzLeft = nan_f, float vertUp = nan_f);
64 
65  virtual
66  DistanceElement getElement(short dx, short dy, bool forward=true) const;
67 
68  // NEW
69  virtual inline
70  float decrease(float value, float coeff) const {
71  return value - coeff;
72  };
73 
74 protected:
75 
76  float radius2Dec(float r, float rDefault) const; // = -1.0
77 
78  float checkDec(float d, float dDefault = 1.0) const;
79 
80 
81 };
82 
83 DRAIN_TYPENAME(DistanceModelLinear);
84 
85 } // image::
86 
87 //DRAIN_TYPENAME(image::DistanceModelLinear);
88 
89 } // drain::
90 
91 #endif /*DISTANCETRANSFORMOP_H_*/
92 
93 
94 
95 
96 
97 // Drain
Definition: DistanceModel.h:76
Definition: DistanceModelLinear.h:51
void setRadius(float horz, float vert=nan_f, float horzLeft=nan_f, float vertUp=nan_f)
Definition: DistanceModelLinear.cpp:53
void setDecrement(float horz, float vert=nan_f, float horzLeft=nan_f, float vertUp=nan_f)
Definition: DistanceModelLinear.cpp:105
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