OTB  10.0.0
Orfeo Toolbox
otbMRFSampler.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2024 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
itk::SmartPointer< Self > Pointer
Definition: otbMRFEnergy.h:154
This is the base class for energy function used in the MRF framework.
Definition: otbMRFEnergy.h:44
itk::SmartPointer< Self > Pointer
Definition: otbMRFEnergy.h:48
This is the base class for sampler methods used in the MRF framework.
Definition: otbMRFSampler.h:45
itk::SmartPointer< const Self > ConstPointer
Definition: otbMRFSampler.h:50
double m_DeltaEnergy
Definition: otbMRFSampler.h:88
itk::Object Superclass
Definition: otbMRFSampler.h:48
double m_EnergyBefore
Definition: otbMRFSampler.h:86
itk::ConstNeighborhoodIterator< TInput1 > InputImageNeighborhoodIterator
Definition: otbMRFSampler.h:52
double m_EnergyAfter
Definition: otbMRFSampler.h:87
MRFEnergy< TInput1, TInput2 > EnergyFidelityType
Definition: otbMRFSampler.h:58
virtual int Compute(const InputImageNeighborhoodIterator &itData, const LabelledImageNeighborhoodIterator &itRegul)=0
~MRFSampler() override
MRFSampler Self
Definition: otbMRFSampler.h:47
itk::SmartPointer< Self > Pointer
Definition: otbMRFSampler.h:49
EnergyFidelityType::Pointer EnergyFidelityPointer
Definition: otbMRFSampler.h:61
EnergyFidelityPointer m_EnergyFidelity
Definition: otbMRFSampler.h:94
itk::NeighborhoodIterator< TInput2 > LabelledImageNeighborhoodIterator
Definition: otbMRFSampler.h:55
double m_EnergyCurrent
Definition: otbMRFSampler.h:89
EnergyRegularizationPointer m_EnergyRegularization
Definition: otbMRFSampler.h:93
TInput2::PixelType LabelledImagePixelType
Definition: otbMRFSampler.h:56
LabelledImagePixelType m_Value
Definition: otbMRFSampler.h:92
EnergyRegularizationType::Pointer EnergyRegularizationPointer
Definition: otbMRFSampler.h:62
MRFEnergy< TInput2, TInput2 > EnergyRegularizationType
Definition: otbMRFSampler.h:59
LabelledImagePixelType m_ValueCurrent
Definition: otbMRFSampler.h:95
TInput1::PixelType InputImagePixelType
Definition: otbMRFSampler.h:53
unsigned int m_NumberOfClasses
Definition: otbMRFSampler.h:85
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.