Loading...
Searching...
No Matches
DistanceModelLinear.h
1/*
2
3MIT License
4
5Copyright (c) 2017 FMI Open Development / Markus Peura, first.last@fmi.fi
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26/*
27Part of Rack development has been done in the BALTRAD projects part-financed
28by the European Union (European Regional Development Fund and European
29Neighbourhood 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
43namespace drain
44{
45
46namespace image
47{
48
49
51{
52
53public:
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
74protected:
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
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
Definition DataSelector.cpp:1277
DRAIN_TYPENAME(void)
Add a specialization for each type of those you want to support.