OTB  10.0.0
Orfeo Toolbox
otbEnvelopeSavitzkyGolayInterpolationFunctor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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::SavitzkyGolayInterpolationFunctor< Radius, TSeries, TDates, TWeight > SGFunctorType
otb::PolynomialTimeSeries< Degree, CoefficientPrecisionType > TSFunctionType
unsigned int doy(const std::tm &d)
Return the day of year.
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.