Orfeo Toolbox  4.0
otbMRFEnergyGaussianClassification.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 
13  This software is distributed WITHOUT ANY WARRANTY; without even
14  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  PURPOSE. See the above copyright notices for more information.
16 
17 =========================================================================*/
18 #ifndef __otbMRFEnergyGaussianClassification_h
19 #define __otbMRFEnergyGaussianClassification_h
20 
21 #include "otbMRFEnergy.h"
22 #include "otbMath.h"
23 
24 namespace otb
25 {
43 template<class TInput1, class TInput2>
44 class ITK_EXPORT MRFEnergyGaussianClassification : public MRFEnergy<TInput1, TInput2>
45 {
46 public:
51 
52  typedef TInput1 InputImageType;
53  typedef TInput2 LabelledImageType;
54  typedef typename InputImageType::PixelType InputImagePixelType;
55  typedef typename LabelledImageType::PixelType LabelledImagePixelType;
57 
58  itkNewMacro(Self);
59 
61 
62  void SetNumberOfParameters(const unsigned int nParameters)
63  {
64  Superclass::SetNumberOfParameters(nParameters);
65  this->m_Parameters.SetSize(nParameters);
66  this->Modified();
67  }
68 
69  double GetSingleValue(const InputImagePixelType& value1, const LabelledImagePixelType& value2)
70  {
71  if ((unsigned int) value2 >= this->GetNumberOfParameters() / 2)
72  {
73  itkExceptionMacro(<< "Number of parameters does not correspond to number of classes");
74  }
75  double val1 = static_cast<double>(value1);
76 
77  double result = vnl_math_sqr(val1 - this->m_Parameters[2 * static_cast<int>(value2)])
78  / (2 * vnl_math_sqr(this->m_Parameters[2 * static_cast<int>(value2) + 1]))
79  + vcl_log(vcl_sqrt(CONST_2PI) * this->m_Parameters[2 * static_cast<int>(value2) + 1]);
80 
81  return static_cast<double>(result);
82  }
83 
84 protected:
85  // The constructor and destructor.
88 
89 };
90 }
91 
92 #endif

Generated at Sat Mar 8 2014 16:09:25 for Orfeo Toolbox with doxygen 1.8.3.1