OTB  9.0.0
Orfeo Toolbox
otbSOM.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 #ifndef otbSOM_h
23 #define otbSOM_h
24 
25 #include "itkImageToImageFilter.h"
26 #include "itkEuclideanDistanceMetric.h"
27 
30 
31 namespace otb
32 {
58 template <class TListSample, class TMap, class TSOMLearningBehaviorFunctor = Functor::CzihoSOMLearningBehaviorFunctor,
59  class TSOMNeighborhoodBehaviorFunctor = Functor::CzihoSOMNeighborhoodBehaviorFunctor>
60 class ITK_EXPORT SOM : public itk::ImageSource<TMap>
61 {
62 public:
63 
65  typedef SOM Self;
66  typedef itk::ImageSource<TMap> Superclass;
67  typedef itk::SmartPointer<Self> Pointer;
68  typedef itk::SmartPointer<const Self> ConstPointer;
69 
71  itkNewMacro(Self);
72 
74  itkTypeMacro(SOM, ImageSource);
75 
76  typedef TListSample ListSampleType;
77  typedef typename ListSampleType::Pointer ListSamplePointerType;
78  typedef TMap MapType;
79  typedef typename MapType::PixelType NeuronType;
80  typedef typename NeuronType::ValueType ValueType;
81  typedef typename MapType::IndexType IndexType;
82  typedef typename MapType::SizeType SizeType;
83  typedef typename MapType::RegionType RegionType;
84  typedef typename MapType::Pointer MapPointerType;
85 
86  typedef TSOMLearningBehaviorFunctor SOMLearningBehaviorFunctorType;
87  typedef TSOMNeighborhoodBehaviorFunctor SOMNeighborhoodBehaviorFunctorType;
88 
90  itkStaticConstMacro(MapDimension, unsigned int, MapType::ImageDimension);
91 
93  itkSetMacro(NumberOfIterations, unsigned int);
94  itkGetMacro(NumberOfIterations, unsigned int);
95  itkSetMacro(BetaInit, double);
96  itkGetMacro(BetaInit, double);
97  itkSetMacro(BetaEnd, double);
98  itkGetMacro(BetaEnd, double);
99  itkSetMacro(MinWeight, ValueType);
100  itkGetMacro(MinWeight, ValueType);
101  itkSetMacro(MaxWeight, ValueType);
102  itkGetMacro(MaxWeight, ValueType);
103  itkSetMacro(MapSize, SizeType);
104  itkGetMacro(MapSize, SizeType);
105  itkSetMacro(NeighborhoodSizeInit, SizeType);
106  itkGetMacro(NeighborhoodSizeInit, SizeType);
107  itkSetMacro(RandomInit, bool);
108  itkGetMacro(RandomInit, bool);
109  itkSetMacro(Seed, unsigned int);
110  itkGetMacro(Seed, unsigned int);
111  itkGetObjectMacro(ListSample, ListSampleType);
112  itkSetObjectMacro(ListSample, ListSampleType);
114 
116  {
117  m_BetaFunctor = functor;
118  }
119 
121  {
122  m_NeighborhoodSizeFunctor = functor;
123  }
124 
125 protected:
127  SOM();
128 
130  ~SOM() override;
131 
133  void GenerateOutputInformation() override;
134 
136  void AllocateOutputs() override;
137 
139  void GenerateData(void) override;
140 
147  virtual void UpdateMap(const NeuronType& sample, double beta, SizeType& radius);
148 
152  virtual void Step(unsigned int currentIteration);
153 
155  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
156 
157 private:
158  SOM(const Self&) = delete;
159  void operator=(const Self&) = delete;
162 
164  unsigned int m_NumberOfIterations;
165 
167  double m_BetaInit;
168 
170  double m_BetaEnd;
171 
174 
177 
180 
183 
185  unsigned int m_Seed;
186 
189 
192 
195 };
196 } // end namespace otb
197 
198 #ifndef OTB_MANUAL_INSTANTIATION
199 #include "otbSOM.hxx"
200 #endif
201 
202 #endif
otb::SOM::MapType
TMap MapType
Definition: otbSOM.h:78
otb::SOM
This class is responsible for the learning of a self organizing map from a set of vector represented ...
Definition: otbSOM.h:60
otbCzihoSOMLearningBehaviorFunctor.h
otb::SOM::Self
SOM Self
Definition: otbSOM.h:65
otb::SOM::m_NeighborhoodSizeInit
SizeType m_NeighborhoodSizeInit
Definition: otbSOM.h:173
otb::SOM::m_Seed
unsigned int m_Seed
Definition: otbSOM.h:185
otb::Functor::CzihoSOMLearningBehaviorFunctor
Beta behavior over SOM training phase.
Definition: otbCzihoSOMLearningBehaviorFunctor.h:65
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SOM::IndexType
MapType::IndexType IndexType
Definition: otbSOM.h:81
otb::SOM::m_ListSample
ListSamplePointerType m_ListSample
Definition: otbSOM.h:188
otb::SOM::SizeType
MapType::SizeType SizeType
Definition: otbSOM.h:82
otb::SOM::ListSamplePointerType
ListSampleType::Pointer ListSamplePointerType
Definition: otbSOM.h:77
otb::SOM::RegionType
MapType::RegionType RegionType
Definition: otbSOM.h:83
otbCzihoSOMNeighborhoodBehaviorFunctor.h
otb::SOM::SOMLearningBehaviorFunctorType
TSOMLearningBehaviorFunctor SOMLearningBehaviorFunctorType
Definition: otbSOM.h:86
otb::SOM::Superclass
itk::ImageSource< TMap > Superclass
Definition: otbSOM.h:66
otb::SOM::m_NumberOfIterations
unsigned int m_NumberOfIterations
Definition: otbSOM.h:164
otb::SOM::SetNeighborhoodSizeFunctor
void SetNeighborhoodSizeFunctor(const SOMNeighborhoodBehaviorFunctorType &functor)
Definition: otbSOM.h:120
otb::SOM::ValueType
NeuronType::ValueType ValueType
Definition: otbSOM.h:80
otb::SOM::MapPointerType
MapType::Pointer MapPointerType
Definition: otbSOM.h:84
otb::SOM::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbSOM.h:68
otb::SOM::ListSampleType
TListSample ListSampleType
Definition: otbSOM.h:74
otb::SOM::SetBetaFunctor
void SetBetaFunctor(const SOMLearningBehaviorFunctorType &functor)
Definition: otbSOM.h:115
otb::SOM::m_MinWeight
ValueType m_MinWeight
Definition: otbSOM.h:176
otb::SOM::m_MapSize
SizeType m_MapSize
Definition: otbSOM.h:161
otb::SOM::m_NeighborhoodSizeFunctor
SOMNeighborhoodBehaviorFunctorType m_NeighborhoodSizeFunctor
Definition: otbSOM.h:194
otbSOM.hxx
otb::SOM::m_BetaFunctor
SOMLearningBehaviorFunctorType m_BetaFunctor
Definition: otbSOM.h:191
otb::SOM::m_BetaInit
double m_BetaInit
Definition: otbSOM.h:167
otb::SOM::m_MaxWeight
ValueType m_MaxWeight
Definition: otbSOM.h:179
otb::Functor::CzihoSOMNeighborhoodBehaviorFunctor
Neighborhood size behavior over SOM training phase.
Definition: otbCzihoSOMNeighborhoodBehaviorFunctor.h:56
otb::SOM::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbSOM.h:67
otb::SOM::m_BetaEnd
double m_BetaEnd
Definition: otbSOM.h:170
otb::SOM::NeuronType
MapType::PixelType NeuronType
Definition: otbSOM.h:79
otb::SOM::m_RandomInit
bool m_RandomInit
Definition: otbSOM.h:182
otb::SOM::SOMNeighborhoodBehaviorFunctorType
TSOMNeighborhoodBehaviorFunctor SOMNeighborhoodBehaviorFunctorType
Definition: otbSOM.h:87