OTB  9.0.0
Orfeo Toolbox
otbSOMbasedImageFilter.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 otbSOMbasedImageFilter_h
23 #define otbSOMbasedImageFilter_h
24 
25 #include "itkMacro.h"
26 #include "itkUnaryFunctorImageFilter.h"
27 
28 namespace otb
29 {
30 
31 namespace Functor
32 {
33 
43 template <class TInput, class TOutput, class TDistanceMetric, class TMap>
45 {
46 public:
49  typedef TMap MapType;
50  typedef typename MapType::Pointer MapPointerType;
51  typedef typename MapType::IndexType IndexType;
52  typedef typename MapType::PixelType NeuronType;
53 
54  typedef TDistanceMetric DistanceType;
55  typedef typename DistanceType::Pointer DistancePointerType;
56 
59  {
60  }
62  {
63  }
65 
67  TOutput operator()(const TInput& input);
68 
70  MapType* GetMap() const
71  {
72  return this->m_Map;
73  }
74  void SetMap(const MapType* theMap);
76 
79  {
80  return this->m_Distance;
81  }
82 
83 protected:
86  IndexType GetWinner(const NeuronType& sample);
87 
90 
91 private:
92  SOMbasedImageFilterFunctor(const Self&); // not implemented
93  void operator=(const Self&); // not implemented
94 };
95 
96 } // end of namespace Functor
97 
116 template <class TInputImage, class TOutputImage, class TDistanceMetric, class TMap>
117 class ITK_EXPORT SOMbasedImageFilter
118  : public itk::UnaryFunctorImageFilter<
119  TInputImage, TOutputImage,
120  Functor::SOMbasedImageFilterFunctor<typename TInputImage::PixelType, typename TOutputImage::PixelType, TDistanceMetric, TMap>>
121 {
122 public:
125  typedef typename itk::UnaryFunctorImageFilter<
128  typedef itk::SmartPointer<Self> Pointer;
129  typedef itk::SmartPointer<const Self> ConstPointer;
130 
132  itkNewMacro(Self);
133 
135  itkTypeMacro(SOMbasedImageFilter, UnaryFunctorImageFilter);
136 
138  typedef TDistanceMetric DistanceMetricType;
139  typedef typename DistanceMetricType::Pointer DistanceMetricPointerType;
140 
141  typedef TMap MapType;
142  typedef typename MapType::Pointer MapPointerType;
143 
145 
147  typedef typename TInputImage::PixelType MeasurementType;
148 
150  void SetMap(const MapType* theMap);
151 
152 protected:
153  // throw the Map to the functor
154  void BeforeThreadedGenerateData(void) override;
155 
158  {
159  }
160 
161 private:
162  SOMbasedImageFilter(const Self&);
163  void operator=(const Self&) = delete;
164 
166 
167 }; // end of class SOMbasedImageFilter
168 
169 } // end of namespace otb
170 
171 #ifndef OTB_MANUAL_INSTANTIATION
173 #endif
174 
175 #endif
otb::Functor::SOMbasedImageFilterFunctor::MapType
TMap MapType
Definition: otbSOMbasedImageFilter.h:49
otb::Functor::SOMbasedImageFilterFunctor::m_Map
MapPointerType m_Map
Definition: otbSOMbasedImageFilter.h:88
otb::Functor::SOMbasedImageFilterFunctor::GetMap
MapType * GetMap() const
Definition: otbSOMbasedImageFilter.h:70
otb::SOMbasedImageFilter::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbSOMbasedImageFilter.h:129
otb::SOMbasedImageFilter::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbSOMbasedImageFilter.h:128
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SOMbasedImageFilter::~SOMbasedImageFilter
~SOMbasedImageFilter() override
Definition: otbSOMbasedImageFilter.h:157
otb::Functor::SOMbasedImageFilterFunctor::DistanceType
TDistanceMetric DistanceType
Definition: otbSOMbasedImageFilter.h:54
otb::Functor::SOMbasedImageFilterFunctor::~SOMbasedImageFilterFunctor
virtual ~SOMbasedImageFilterFunctor()
Definition: otbSOMbasedImageFilter.h:61
otb::Functor::SOMbasedImageFilterFunctor::GetDistance
DistanceType * GetDistance()
Definition: otbSOMbasedImageFilter.h:78
otb::SOMbasedImageFilter::DistanceMetricPointerType
DistanceMetricType::Pointer DistanceMetricPointerType
Definition: otbSOMbasedImageFilter.h:139
otb::SOMbasedImageFilter::m_Map
MapPointerType m_Map
Definition: otbSOMbasedImageFilter.h:165
otb::SOMbasedImageFilter::MeasurementType
TInputImage::PixelType MeasurementType
Definition: otbSOMbasedImageFilter.h:147
otb::SOMbasedImageFilter::Superclass
itk::UnaryFunctorImageFilter< TInputImage, TOutputImage, Functor::SOMbasedImageFilterFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType, TDistanceMetric, TMap > > Superclass
Definition: otbSOMbasedImageFilter.h:127
otb::Functor::SOMbasedImageFilterFunctor::MapPointerType
MapType::Pointer MapPointerType
Definition: otbSOMbasedImageFilter.h:50
otb::SOMbasedImageFilter::FunctorType
Functor::SOMbasedImageFilterFunctor< typename TInputImage::PixelType, typename TOutputImage::PixelType, TDistanceMetric, TMap > FunctorType
Definition: otbSOMbasedImageFilter.h:144
otb::Functor::SOMbasedImageFilterFunctor::m_Distance
DistancePointerType m_Distance
Definition: otbSOMbasedImageFilter.h:89
otb::Functor::SOMbasedImageFilterFunctor
This class implements the functor that perform substitution between input image pixels and the corres...
Definition: otbSOMbasedImageFilter.h:44
otb::Functor::SOMbasedImageFilterFunctor::IndexType
MapType::IndexType IndexType
Definition: otbSOMbasedImageFilter.h:51
otb::Functor::SOMbasedImageFilterFunctor::SOMbasedImageFilterFunctor
SOMbasedImageFilterFunctor()
Definition: otbSOMbasedImageFilter.h:58
otb::Functor::SOMbasedImageFilterFunctor::DistancePointerType
DistanceType::Pointer DistancePointerType
Definition: otbSOMbasedImageFilter.h:55
otb::SOMbasedImageFilter::DistanceMetricType
TDistanceMetric DistanceMetricType
Definition: otbSOMbasedImageFilter.h:135
otb::SOMbasedImageFilter
This class perform the substitution between initial input image pixels and the winning neurons of a S...
Definition: otbSOMbasedImageFilter.h:117
otb::Functor::SOMbasedImageFilterFunctor::NeuronType
MapType::PixelType NeuronType
Definition: otbSOMbasedImageFilter.h:52
otb::SOMbasedImageFilter::MapType
TMap MapType
Definition: otbSOMbasedImageFilter.h:141
otbSOMbasedImageFilter.hxx
otb::Functor::SOMbasedImageFilterFunctor::Self
SOMbasedImageFilterFunctor Self
Definition: otbSOMbasedImageFilter.h:48
otb::SOMbasedImageFilter::MapPointerType
MapType::Pointer MapPointerType
Definition: otbSOMbasedImageFilter.h:142
otb::SOMbasedImageFilter::Self
SOMbasedImageFilter Self
Definition: otbSOMbasedImageFilter.h:124