OTB  9.0.0
Orfeo Toolbox
otbEnvelopeSavitzkyGolayInterpolationFunctor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbEnvelopeSavitzkyGolayInterpolationFunctor_h
22 #define otbEnvelopeSavitzkyGolayInterpolationFunctor_h
23 
25 
26 
27 namespace otb
28 {
29 namespace Functor
30 {
40 template <unsigned int Radius, class TSeries, class TDates, class TWeight = TSeries>
42 {
43 public:
44  typedef typename TSeries::ValueType ValueType;
45  typedef typename TDates::ValueType DateType;
46  typedef typename TWeight::ValueType WeightType;
47  static const unsigned int Degree = 2;
48  typedef double CoefficientPrecisionType;
50  static const unsigned int nbDates = TSeries::Dimension;
51 
53 
56  {
57  }
60  {
61  }
62 
63  inline void SetWeights(const TWeight weights)
64  {
65  for (unsigned int i = 0; i < m_WeightSeries.Size(); ++i)
66  m_WeightSeries[i] = weights[i];
67  m_SGFunctor.SetWeights(weights);
68  }
69 
70  inline void SetDates(const TDates doy)
71  {
73  }
74 
75  inline void SetUpperEnvelope()
76  {
77  m_UpperEnvelope = true;
78  }
79 
80  inline void SetLowerEnvelope()
81  {
82  m_UpperEnvelope = false;
83  }
84 
85  inline void SetDecreaseFactor(double df)
86  {
87  if (df > 0.0 && df < 1.0)
88  m_DecreaseFactor = df;
89  }
90 
91  inline void SetIterations(unsigned int its)
92  {
93  m_Iterations = its;
94  }
95 
96  inline TSeries operator()(const TSeries& series)
97  {
98  TSeries outSeries = m_SGFunctor(series);
99 
100  for (unsigned int i = 0; i < m_Iterations; ++i)
101  {
102  for (unsigned int j = 0; j < nbDates; ++j)
103  {
104  if (m_UpperEnvelope && outSeries[j] < series[j])
106  if (!m_UpperEnvelope && outSeries[j] > series[j])
108  }
109 
111  outSeries = m_SGFunctor(series);
112  }
113 
114  return outSeries;
115  }
116 
117 private:
118  TWeight m_WeightSeries;
120  unsigned int m_Iterations;
123 };
124 }
125 } // namespace otb
126 #endif
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::WeightType
TWeight::ValueType WeightType
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:46
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::m_UpperEnvelope
bool m_UpperEnvelope
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:121
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::ValueType
TSeries::ValueType ValueType
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:44
otb::Functor::SavitzkyGolayInterpolationFunctor::SetDates
void SetDates(const TDates doy)
Definition: otbSavitzkyGolayInterpolationFunctor.h:90
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::m_Iterations
unsigned int m_Iterations
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:120
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::SetLowerEnvelope
void SetLowerEnvelope()
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:80
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::operator()
TSeries operator()(const TSeries &series)
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:96
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::Degree
static const unsigned int Degree
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:47
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::m_WeightSeries
TWeight m_WeightSeries
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:118
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::~EnvelopeSavitzkyGolayInterpolationFunctor
virtual ~EnvelopeSavitzkyGolayInterpolationFunctor()
Destructor.
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:59
otb::Functor::SavitzkyGolayInterpolationFunctor::SetWeights
void SetWeights(const TWeight weights)
Definition: otbSavitzkyGolayInterpolationFunctor.h:84
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::m_SGFunctor
SGFunctorType m_SGFunctor
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:119
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:41
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::nbDates
static const unsigned int nbDates
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:50
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::SetIterations
void SetIterations(unsigned int its)
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:91
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::m_DecreaseFactor
double m_DecreaseFactor
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:122
GapFilling::doy
unsigned int doy(const std::tm &d)
Return the day of year.
otbSavitzkyGolayInterpolationFunctor.h
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::EnvelopeSavitzkyGolayInterpolationFunctor
EnvelopeSavitzkyGolayInterpolationFunctor()
Constructor.
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:55
otb::Functor::SavitzkyGolayInterpolationFunctor
Definition: otbSavitzkyGolayInterpolationFunctor.h:57
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::DateType
TDates::ValueType DateType
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:45
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::CoefficientPrecisionType
double CoefficientPrecisionType
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:48
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::SetUpperEnvelope
void SetUpperEnvelope()
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:75
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::SGFunctorType
otb::Functor::SavitzkyGolayInterpolationFunctor< Radius, TSeries, TDates, TWeight > SGFunctorType
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:52
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::SetWeights
void SetWeights(const TWeight weights)
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:63
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::SetDates
void SetDates(const TDates doy)
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:70
otb::PolynomialTimeSeries
Definition: otbTimeSeries.h:30
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::SetDecreaseFactor
void SetDecreaseFactor(double df)
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:85
otb::Functor::EnvelopeSavitzkyGolayInterpolationFunctor::TSFunctionType
otb::PolynomialTimeSeries< Degree, CoefficientPrecisionType > TSFunctionType
Definition: otbEnvelopeSavitzkyGolayInterpolationFunctor.h:49