OTB  9.0.0
Orfeo Toolbox
otbCzihoSOMLearningBehaviorFunctor.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  * Copyright (C) 2007-2012 Institut Mines Telecom / Telecom Bretagne
4  *
5  * This file is part of Orfeo Toolbox
6  *
7  * https://www.orfeo-toolbox.org/
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  */
21 
22 
23 #ifndef otbCzihoSOMLearningBehaviorFunctor_h
24 #define otbCzihoSOMLearningBehaviorFunctor_h
25 
26 #include "itkSize.h"
27 #include "otbMath.h"
28 
29 namespace otb
30 {
31 
32 namespace Functor
33 {
34 
66 {
67 public:
70  {
72  }
74  {
75  }
77 
79  unsigned int GetIterationThreshold()
80  {
81  return this->m_IterationThreshold;
82  }
83 
84  template <unsigned int VDimension>
85  void SetIterationThreshold(const itk::Size<VDimension>& sizeInit, unsigned int iterMax)
86  {
87  double V0 = static_cast<double>(sizeInit[0]);
88  for (unsigned int i = 1; i < VDimension; ++i)
89  {
90  if (V0 < static_cast<double>(sizeInit[i]))
91  V0 = static_cast<double>(sizeInit[i]);
92  }
93 
94  m_IterationThreshold = static_cast<unsigned int>(static_cast<double>(iterMax) * (1.0 - 1.0 / ::std::sqrt(V0)));
95  }
96 
98  virtual double operator()(unsigned int currentIteration, unsigned int numberOfIterations, double betaInit, double betaEnd) const
99  {
100  if (currentIteration < m_IterationThreshold)
101  {
102  return betaInit * (1.0 - static_cast<double>(currentIteration) / static_cast<double>(numberOfIterations));
103  }
104  else
105  {
106  return betaEnd * (1.0 - static_cast<double>(currentIteration - m_IterationThreshold) / static_cast<double>(numberOfIterations - m_IterationThreshold));
107  }
108  }
110 
111 private:
112  unsigned int m_IterationThreshold;
113 
114 }; // end of class CzihoSOMLearningBehaviorFunctor
115 
116 } // end namespace Functor
117 
118 } // end namespace otb
119 
120 #endif
otb::Functor::CzihoSOMLearningBehaviorFunctor::SetIterationThreshold
void SetIterationThreshold(const itk::Size< VDimension > &sizeInit, unsigned int iterMax)
Definition: otbCzihoSOMLearningBehaviorFunctor.h:85
otb::Functor::CzihoSOMLearningBehaviorFunctor::operator()
virtual double operator()(unsigned int currentIteration, unsigned int numberOfIterations, double betaInit, double betaEnd) const
Definition: otbCzihoSOMLearningBehaviorFunctor.h:98
otb::Functor::CzihoSOMLearningBehaviorFunctor::GetIterationThreshold
unsigned int GetIterationThreshold()
Definition: otbCzihoSOMLearningBehaviorFunctor.h:79
otb::Functor::CzihoSOMLearningBehaviorFunctor
Beta behavior over SOM training phase.
Definition: otbCzihoSOMLearningBehaviorFunctor.h:65
otbMath.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::Functor::CzihoSOMLearningBehaviorFunctor::CzihoSOMLearningBehaviorFunctor
CzihoSOMLearningBehaviorFunctor()
Definition: otbCzihoSOMLearningBehaviorFunctor.h:69
otb::Functor::CzihoSOMLearningBehaviorFunctor::~CzihoSOMLearningBehaviorFunctor
virtual ~CzihoSOMLearningBehaviorFunctor()
Definition: otbCzihoSOMLearningBehaviorFunctor.h:73
otb::Functor::CzihoSOMLearningBehaviorFunctor::m_IterationThreshold
unsigned int m_IterationThreshold
Definition: otbCzihoSOMLearningBehaviorFunctor.h:112