OTB  10.0.0
Orfeo Toolbox
otbSOM.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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);
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
This class is responsible for the learning of a self organizing map from a set of vector represented ...
Definition: otbSOM.h:61
itkGetObjectMacro(ListSample, ListSampleType)
SOM(const Self &)=delete
unsigned int m_NumberOfIterations
Definition: otbSOM.h:164
SizeType m_MapSize
Definition: otbSOM.h:161
void SetNeighborhoodSizeFunctor(const SOMNeighborhoodBehaviorFunctorType &functor)
Definition: otbSOM.h:120
TSOMNeighborhoodBehaviorFunctor SOMNeighborhoodBehaviorFunctorType
Definition: otbSOM.h:87
SOMNeighborhoodBehaviorFunctorType m_NeighborhoodSizeFunctor
Definition: otbSOM.h:194
ListSamplePointerType m_ListSample
Definition: otbSOM.h:188
itk::SmartPointer< const Self > ConstPointer
Definition: otbSOM.h:68
MapType::PixelType NeuronType
Definition: otbSOM.h:79
SOMLearningBehaviorFunctorType m_BetaFunctor
Definition: otbSOM.h:191
SizeType m_NeighborhoodSizeInit
Definition: otbSOM.h:173
ValueType m_MinWeight
Definition: otbSOM.h:176
double m_BetaInit
Definition: otbSOM.h:167
bool m_RandomInit
Definition: otbSOM.h:182
MapType::IndexType IndexType
Definition: otbSOM.h:81
void operator=(const Self &)=delete
unsigned int m_Seed
Definition: otbSOM.h:185
MapType::Pointer MapPointerType
Definition: otbSOM.h:84
itk::ImageSource< TMap > Superclass
Definition: otbSOM.h:66
itk::SmartPointer< Self > Pointer
Definition: otbSOM.h:67
TListSample ListSampleType
Definition: otbSOM.h:74
MapType::RegionType RegionType
Definition: otbSOM.h:83
NeuronType::ValueType ValueType
Definition: otbSOM.h:80
MapType::SizeType SizeType
Definition: otbSOM.h:82
double m_BetaEnd
Definition: otbSOM.h:170
TSOMLearningBehaviorFunctor SOMLearningBehaviorFunctorType
Definition: otbSOM.h:86
void SetBetaFunctor(const SOMLearningBehaviorFunctorType &functor)
Definition: otbSOM.h:115
ValueType m_MaxWeight
Definition: otbSOM.h:179
SOM Self
Definition: otbSOM.h:65
ListSampleType::Pointer ListSamplePointerType
Definition: otbSOM.h:77
TMap MapType
Definition: otbSOM.h:78
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.