OTB  9.0.0
Orfeo Toolbox
otbMRFSampler.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2022 Centre National d'Etudes Spatiales (CNES)
3  *
4  * This file is part of Orfeo Toolbox
5  *
6  * https://www.orfeo-toolbox.org/
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 
21 #ifndef otbMRFSampler_h
22 #define otbMRFSampler_h
23 
24 #include "otbMRFEnergy.h"
25 #include "itkNeighborhoodIterator.h"
26 
27 namespace otb
28 {
43 template <class TInput1, class TInput2>
44 class ITK_EXPORT MRFSampler : public itk::Object
45 {
46 public:
47  typedef MRFSampler Self;
48  typedef itk::Object Superclass;
49  typedef itk::SmartPointer<Self> Pointer;
50  typedef itk::SmartPointer<const Self> ConstPointer;
51 
52  typedef itk::ConstNeighborhoodIterator<TInput1> InputImageNeighborhoodIterator;
53  typedef typename TInput1::PixelType InputImagePixelType;
54 
55  typedef itk::NeighborhoodIterator<TInput2> LabelledImageNeighborhoodIterator;
56  typedef typename TInput2::PixelType LabelledImagePixelType;
57 
60 
63 
64  itkTypeMacro(MRFSampler, Object);
65 
66  itkSetMacro(NumberOfClasses, unsigned int);
67  itkGetMacro(NumberOfClasses, unsigned int);
68 
69  itkSetMacro(Lambda, double);
70  itkGetMacro(Lambda, double);
71 
72  itkGetMacro(DeltaEnergy, double);
73  itkGetMacro(Value, LabelledImagePixelType);
74 
75  // Accessor for validation tests pour les tests
76  itkGetConstMacro(EnergyBefore, double);
77  itkGetConstMacro(EnergyAfter, double);
78 
79  itkSetObjectMacro(EnergyRegularization, EnergyRegularizationType);
80  itkSetObjectMacro(EnergyFidelity, EnergyFidelityType);
81 
82  virtual int Compute(const InputImageNeighborhoodIterator& itData, const LabelledImageNeighborhoodIterator& itRegul) = 0;
83 
84 protected:
85  unsigned int m_NumberOfClasses;
87  double m_EnergyAfter;
88  double m_DeltaEnergy;
90  double m_Lambda;
91 
96 
97 protected:
98  // The constructor and destructor.
99  MRFSampler() : m_NumberOfClasses(1), m_EnergyBefore(1.0), m_EnergyAfter(1.0), m_DeltaEnergy(1.0), m_EnergyCurrent(1.0), m_Lambda(1.0)
100  {
101  m_EnergyRegularization = EnergyRegularizationType::New();
102  m_EnergyFidelity = EnergyFidelityType::New();
103  };
104  ~MRFSampler() override
105  {
106  }
107 };
108 }
109 
110 #endif
otb::MRFSampler::m_ValueCurrent
LabelledImagePixelType m_ValueCurrent
Definition: otbMRFSampler.h:95
otb::MRFSampler::m_Lambda
double m_Lambda
Definition: otbMRFSampler.h:90
otb::MRFEnergy< TInput2, TInput2 >
Definition: otbMRFEnergy.h:149
otb::MRFSampler::EnergyRegularizationPointer
EnergyRegularizationType::Pointer EnergyRegularizationPointer
Definition: otbMRFSampler.h:62
otb::MRFEnergy::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMRFEnergy.h:48
otb::MRFSampler::EnergyRegularizationType
MRFEnergy< TInput2, TInput2 > EnergyRegularizationType
Definition: otbMRFSampler.h:59
otb::MRFSampler::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMRFSampler.h:49
otb::MRFSampler::~MRFSampler
~MRFSampler() override
Definition: otbMRFSampler.h:104
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::MRFSampler::InputImageNeighborhoodIterator
itk::ConstNeighborhoodIterator< TInput1 > InputImageNeighborhoodIterator
Definition: otbMRFSampler.h:52
otb::MRFSampler::m_EnergyRegularization
EnergyRegularizationPointer m_EnergyRegularization
Definition: otbMRFSampler.h:93
otb::MRFSampler::Self
MRFSampler Self
Definition: otbMRFSampler.h:47
otb::MRFSampler::m_NumberOfClasses
unsigned int m_NumberOfClasses
Definition: otbMRFSampler.h:85
otbMRFEnergy.h
otb::MRFSampler::m_DeltaEnergy
double m_DeltaEnergy
Definition: otbMRFSampler.h:88
otb::MRFSampler::m_EnergyAfter
double m_EnergyAfter
Definition: otbMRFSampler.h:87
otb::MRFSampler::EnergyFidelityPointer
EnergyFidelityType::Pointer EnergyFidelityPointer
Definition: otbMRFSampler.h:61
otb::MRFSampler::m_EnergyFidelity
EnergyFidelityPointer m_EnergyFidelity
Definition: otbMRFSampler.h:94
otb::MRFSampler
This is the base class for sampler methods used in the MRF framework.
Definition: otbMRFSampler.h:44
otb::MRFSampler::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbMRFSampler.h:50
otb::MRFSampler::LabelledImagePixelType
TInput2::PixelType LabelledImagePixelType
Definition: otbMRFSampler.h:56
otb::MRFEnergy< TInput2, TInput2 >::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbMRFEnergy.h:154
otb::MRFSampler::MRFSampler
MRFSampler()
Definition: otbMRFSampler.h:99
otb::MRFSampler::LabelledImageNeighborhoodIterator
itk::NeighborhoodIterator< TInput2 > LabelledImageNeighborhoodIterator
Definition: otbMRFSampler.h:55
otb::MRFSampler::m_Value
LabelledImagePixelType m_Value
Definition: otbMRFSampler.h:92
otb::MRFEnergy
This is the base class for energy function used in the MRF framework.
Definition: otbMRFEnergy.h:43
otb::MRFSampler::InputImagePixelType
TInput1::PixelType InputImagePixelType
Definition: otbMRFSampler.h:53
otb::MRFSampler::EnergyFidelityType
MRFEnergy< TInput1, TInput2 > EnergyFidelityType
Definition: otbMRFSampler.h:58
otb::MRFSampler::m_EnergyCurrent
double m_EnergyCurrent
Definition: otbMRFSampler.h:89
otb::MRFSampler::m_EnergyBefore
double m_EnergyBefore
Definition: otbMRFSampler.h:86
otb::MRFSampler::Superclass
itk::Object Superclass
Definition: otbMRFSampler.h:48