OTB  6.1.0
Orfeo Toolbox
otbSEMClassifier.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2017 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 otbSEMClassifier_h
23 #define otbSEMClassifier_h
24 
25 #include "itkListSample.h"
27 
28 
30 
31 namespace otb
32 {
33 
63 template<class TInputImage, class TOutputImage>
64 class ITK_EXPORT SEMClassifier
66  typename itk::Statistics::ListSample<typename TInputImage::PixelType> >
67 {
68 public:
76 
78  itkTypeMacro(SEMClassifier, itk::Object);
79  itkNewMacro(Self);
81 
85 
88 
90  typedef unsigned int ClassLabelType;
91  typedef std::vector<ClassLabelType> ClassLabelVectorType;
92 
95 
102 
104  typedef std::vector<ComponentPointerType> ComponentVectorType;
105 
108 
110  typedef std::vector<ParameterType> ParameterVectorType;
111 
113  typedef std::vector<double> ProportionVectorType;
114  typedef std::vector<double> ProbaVectorType;
115 
117  typedef std::vector<ProbaVectorType> ProbaByClassVectorType;
118 
120  void SetSample(const TInputImage * sample);
121 
123  const TInputImage* GetSample() const;
124  SampleType * GetSampleList() const;
126 
131  void SetInitialProportions(ProportionVectorType& propotion);
132  ProportionVectorType* GetInitialProportions();
134 
136  ProportionVectorType* GetProportions();
137 
140  void SetClassLabels(OutputType * labels);
141  void SetClassLabels(TOutputImage * imgLabels);
142  ClassLabelVectorType& GetClassLabels();
144 
149  itkSetMacro(MaximumIteration, int);
150  itkGetMacro(MaximumIteration, int);
152 
155  void SetNeighborhood(int neighborhood);
156  int GetNeighborhood();
158 
160  int GetCurrentIteration();
161 
163  int AddComponent(int id, ComponentType* component);
164 
166  void Update() ITK_OVERRIDE;
167 
169  typedef enum { CONVERGED = 0, NOT_CONVERGED = 1 } TerminationCodeType;
170 
174  itkSetMacro(TerminationThreshold, double);
175  itkGetMacro(TerminationThreshold, double);
177 
179  itkGetMacro(TerminationCode, TerminationCodeType);
180 
181  /* Return the classification result (as a standard classification result) */
182  OutputType * GetOutput();
183 
184  /* Return the classification result (as an image) */
185  TOutputImage * GetOutputImage();
186 
187  void Modified() const ITK_OVERRIDE;
188 
189 protected:
190  SEMClassifier();
191  ~SEMClassifier() ITK_OVERRIDE {}
192  void PrintSelf(std::ostream& os, itk::Indent indent) const ITK_OVERRIDE;
193 
196  void InitParameters();
197 
199  void PerformStochasticProcess();
200 
202  void PerformExpectationProcess();
203 
207  void PerformMaximizationProcess();
208 
210  void GetMaximumAposterioriLabels();
211 
212 private:
214  const TInputImage* m_Sample;
217 
223 
230 
232  mutable int m_ComponentDeclared;
233 
234  typename TOutputImage::Pointer m_OutputImage;
236 }; // end of class
237 
238 } // end of namespace
239 
240 #ifndef OTB_MANUAL_INSTANTIATION
241 #include "otbSEMClassifier.txx"
242 #endif
243 
244 #endif
This class implements the Stochastic Expectation Maximization algorithm to perform an estimation of a...
std::vector< ProbaVectorType > ProbaByClassVectorType
itk::Array< double > ParameterType
itk::Statistics::Subsample< SampleType > ClassSampleType
ProportionVectorType m_InitialProportions
std::vector< ParameterType > ParameterVectorType
Superclass::MeasurementType MeasurementType
TOutputImage::Pointer m_OutputImage
Superclass::MeasurementVectorType MeasurementVectorType
SampleType::Pointer m_SampleList
itk::SmartPointer< Self > Pointer
std::vector< double > ProportionVectorType
itk::Statistics::SampleClassifierFilter< typename itk::Statistics::ListSample< typename TInputImage::PixelType > > Superclass
ProportionVectorType m_Proportions
unsigned int ClassLabelType
OutputType::Pointer m_Output
ClassLabelVectorType m_ClassLabels
otb::Statistics::ModelComponentBase< ClassSampleType > ComponentType
const TInputImage * m_Sample
SEMClassifier Self
std::vector< ComponentPointerType > ComponentVectorType
base class for distribution representation that supports analytical way to update the distribution pa...
itk::Statistics::ListSample< typename TInputImage::PixelType > SampleType
itk::Statistics::MembershipSample< SampleType > OutputType
TerminationCodeType m_TerminationCode
ComponentVectorType m_ComponentVector
ProbaByClassVectorType m_Proba
itk::SmartPointer< const Self > ConstPointer
std::vector< double > ProbaVectorType
ComponentType::Pointer ComponentPointerType
SampleType::MeasurementVectorType MeasurementVectorType
SampleType::MeasurementType MeasurementType
std::vector< ClassLabelType > ClassLabelVectorType