OTB  5.0.0
Orfeo Toolbox
otbSEMClassifier.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ORFEO Toolbox
4  Language: C++
5  Date: $Date$
6  Version: $Revision$
7 
8 
9  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
10  See OTBCopyright.txt for details.
11 
12  Some parts of this code are covered by the GET copyright.
13  See GETCopyright.txt for details.
14 
15  This software is distributed WITHOUT ANY WARRANTY; without even
16  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
17  PURPOSE. See the above copyright notices for more information.
18 
19 =========================================================================*/
20 #ifndef __otbSEMClassifier_h
21 #define __otbSEMClassifier_h
22 
23 #include "itkListSample.h"
25 
26 
28 
29 namespace otb
30 {
31 
61 template<class TInputImage, class TOutputImage>
62 class ITK_EXPORT SEMClassifier
64  typename itk::Statistics::ListSample<typename TInputImage::PixelType> >
65 {
66 public:
74 
76  itkTypeMacro(SEMClassifier, itk::Object);
77  itkNewMacro(Self);
79 
83 
86 
88  typedef unsigned int ClassLabelType;
89  typedef std::vector<ClassLabelType> ClassLabelVectorType;
90 
93 
100 
102  typedef std::vector<ComponentPointerType> ComponentVectorType;
103 
106 
108  typedef std::vector<ParameterType> ParameterVectorType;
109 
111  typedef std::vector<double> ProportionVectorType;
112  typedef std::vector<double> ProbaVectorType;
113 
115  typedef std::vector<ProbaVectorType> ProbaByClassVectorType;
116 
118  void SetSample(const TInputImage * sample);
119 
121  const TInputImage* GetSample() const;
122  SampleType * GetSampleList() const;
124 
129  void SetInitialProportions(ProportionVectorType& propotion);
130  ProportionVectorType* GetInitialProportions();
132 
134  ProportionVectorType* GetProportions();
135 
138  void SetClassLabels(OutputType * labels);
139  void SetClassLabels(TOutputImage * imgLabels);
140  ClassLabelVectorType& GetClassLabels();
142 
147  itkSetMacro(MaximumIteration, int);
148  itkGetMacro(MaximumIteration, int);
150 
153  void SetNeighborhood(int neighborhood);
154  int GetNeighborhood();
156 
158  int GetCurrentIteration();
159 
161  int AddComponent(int id, ComponentType* component);
162 
164  void Update();
165 
167  typedef enum { CONVERGED = 0, NOT_CONVERGED = 1 } TerminationCodeType;
168 
172  itkSetMacro(TerminationThreshold, double);
173  itkGetMacro(TerminationThreshold, double);
175 
177  itkGetMacro(TerminationCode, TerminationCodeType);
178 
179  /* Return the classification result (as a standard classification result) */
180  OutputType * GetOutput();
181 
182  /* Return the classification result (as an image) */
183  TOutputImage * GetOutputImage();
184 
185  virtual void Modified() const;
186 
187 protected:
188  SEMClassifier();
189  virtual ~SEMClassifier() {}
190  void PrintSelf(std::ostream& os, itk::Indent indent) const;
191 
194  void InitParameters();
195 
197  void PerformStochasticProcess();
198 
200  void PerformExpectationProcess();
201 
205  void PerformMaximizationProcess();
206 
208  void GetMaximumAposterioriLabels();
209 
210 private:
212  const TInputImage* m_Sample;
215 
221 
228 
230  mutable int m_ComponentDeclared;
231 
232  typename TOutputImage::Pointer m_OutputImage;
234 }; // end of class
235 
236 } // end of namespace
237 
238 #ifndef OTB_MANUAL_INSTANTIATION
239 #include "otbSEMClassifier.txx"
240 #endif
241 
242 #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