OTB  9.0.0
Orfeo Toolbox
otbConfusionMatrixToMassOfBelief.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 otbConfusionMatrixToMassOfBelief_h
22 #define otbConfusionMatrixToMassOfBelief_h
23 
24 // First make sure that the configuration is available.
25 // This line can be removed once the optimized versions
26 // gets integrated into the main directories.
27 #include "itkConfigure.h"
28 
29 #include "itkProcessObject.h"
31 
32 
33 namespace otb
34 {
54 template <class TConfusionMatrix = itk::VariableSizeMatrix<double>, class TLabel = int>
55 class ITK_EXPORT ConfusionMatrixToMassOfBelief : public itk::ProcessObject
56 {
57 public:
60  typedef itk::ProcessObject Superclass;
61  typedef itk::SmartPointer<Self> Pointer;
62  typedef itk::SmartPointer<const Self> ConstPointer;
63 
65  itkTypeMacro(ConfusionMatrixToMassOfBelief, itk::ProcessObject);
66 
68  itkNewMacro(Self);
69 
70 
72  typedef TConfusionMatrix ConfusionMatrixType;
73 
75  typedef TLabel ClassLabelType;
76 
81 
82  typedef double MassType;
83  typedef std::map<ClassLabelType, MassType> LabelMassMapType;
84 
86  {
90  KAPPA
91  };
92 
93  void Update() override;
94 
96  itkSetMacro(ConfusionMatrix, ConfusionMatrixType);
97  itkSetMacro(DefinitionMethod, MassOfBeliefDefinitionMethod);
99 
100  /* Gives the correspondence between a class label
101  * and its index in the confusion matrix
102  */
103  virtual void SetMapOfClasses(const MapOfClassesType _arg)
104  {
105  m_MapOfClasses = _arg;
106  typename MapOfClassesType::iterator itMapOfClasses;
107  m_MapOfIndices.clear();
108  for (itMapOfClasses = m_MapOfClasses.begin(); itMapOfClasses != m_MapOfClasses.end(); ++itMapOfClasses)
109  {
110  m_MapOfIndices[itMapOfClasses->second] = itMapOfClasses->first;
111  }
112  }
113 
115  {
116  return m_MapOfClasses;
117  }
118 
119  /* Gives the correspondence between an index in the
120  * confusion matrix and the class label
121  */
122  virtual void SetMapOfIndices(const MapOfIndicesType _arg)
123  {
124  m_MapOfIndices = _arg;
125  typename MapOfIndicesType::iterator itMapOfIndices;
126  m_MapOfClasses.clear();
127  for (itMapOfIndices = m_MapOfIndices.begin(); itMapOfIndices != m_MapOfIndices.end(); ++itMapOfIndices)
128  {
129  m_MapOfClasses[itMapOfIndices->second] = itMapOfIndices->first;
130  }
131  }
132 
134  {
135  return m_MapOfIndices;
136  }
137 
138 
140  {
141  return m_MapMassOfBelief;
142  }
143 
144 
145 protected:
148 
151 
153  void GenerateData(void) override;
154 
155 private:
156  ConfusionMatrixToMassOfBelief(const Self&) = delete;
157  void operator=(const Self&) = delete;
158 
161 
164 
167 };
168 
169 } // end namespace otb
170 
171 
172 #ifndef OTB_MANUAL_INSTANTIATION
174 #endif
175 
176 #endif
otb::ConfusionMatrixToMassOfBelief::PRECISION
@ PRECISION
Definition: otbConfusionMatrixToMassOfBelief.h:87
otb::ConfusionMatrixToMassOfBelief::MapOfIndicesType
ConfusionMatrixMeasurementsType::MapOfIndicesType MapOfIndicesType
Definition: otbConfusionMatrixToMassOfBelief.h:80
otb::ConfusionMatrixToMassOfBelief::MapOfClassesType
ConfusionMatrixMeasurementsType::MapOfClassesType MapOfClassesType
Definition: otbConfusionMatrixToMassOfBelief.h:79
otb::ConfusionMatrixToMassOfBelief::m_ConfMatMeasurements
ConfusionMatrixMeasurementsType::Pointer m_ConfMatMeasurements
Definition: otbConfusionMatrixToMassOfBelief.h:160
otb::ConfusionMatrixToMassOfBelief::MassType
double MassType
Definition: otbConfusionMatrixToMassOfBelief.h:82
otb::ConfusionMatrixToMassOfBelief::~ConfusionMatrixToMassOfBelief
~ConfusionMatrixToMassOfBelief() override
Definition: otbConfusionMatrixToMassOfBelief.h:150
otb::ConfusionMatrixMeasurements::MapOfIndicesType
std::map< int, ClassLabelType > MapOfIndicesType
Definition: otbConfusionMatrixMeasurements.h:70
otbConfusionMatrixToMassOfBelief.hxx
otb::ConfusionMatrixToMassOfBelief
This class converts a confusion matrix into masses of belief for each label.
Definition: otbConfusionMatrixToMassOfBelief.h:55
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::ConfusionMatrixToMassOfBelief::ClassLabelType
TLabel ClassLabelType
Definition: otbConfusionMatrixToMassOfBelief.h:75
otb::ConfusionMatrixToMassOfBelief::ConfusionMatrixType
TConfusionMatrix ConfusionMatrixType
Definition: otbConfusionMatrixToMassOfBelief.h:68
otbConfusionMatrixMeasurements.h
otb::ConfusionMatrixToMassOfBelief::m_MapOfIndices
MapOfIndicesType m_MapOfIndices
Definition: otbConfusionMatrixToMassOfBelief.h:163
otb::ConfusionMatrixMeasurements
Definition: otbConfusionMatrixMeasurements.h:53
otb::ConfusionMatrixToMassOfBelief::ACCURACY
@ ACCURACY
Definition: otbConfusionMatrixToMassOfBelief.h:89
otb::ConfusionMatrixToMassOfBelief::m_ConfusionMatrix
ConfusionMatrixType m_ConfusionMatrix
Definition: otbConfusionMatrixToMassOfBelief.h:159
otb::ConfusionMatrixToMassOfBelief::SetMapOfIndices
virtual void SetMapOfIndices(const MapOfIndicesType _arg)
Definition: otbConfusionMatrixToMassOfBelief.h:122
otb::ConfusionMatrixMeasurements::MapOfClassesType
std::map< ClassLabelType, int > MapOfClassesType
Definition: otbConfusionMatrixMeasurements.h:69
otb::ConfusionMatrixToMassOfBelief::SetMapOfClasses
virtual void SetMapOfClasses(const MapOfClassesType _arg)
Definition: otbConfusionMatrixToMassOfBelief.h:103
otb::ConfusionMatrixToMassOfBelief::MassOfBeliefDefinitionMethod
MassOfBeliefDefinitionMethod
Definition: otbConfusionMatrixToMassOfBelief.h:85
otb::ConfusionMatrixToMassOfBelief::GetMapMassOfBelief
LabelMassMapType GetMapMassOfBelief() const
Definition: otbConfusionMatrixToMassOfBelief.h:139
otb::ConfusionMatrixToMassOfBelief::LabelMassMapType
std::map< ClassLabelType, MassType > LabelMassMapType
Definition: otbConfusionMatrixToMassOfBelief.h:83
otb::ConfusionMatrixToMassOfBelief::RECALL
@ RECALL
Definition: otbConfusionMatrixToMassOfBelief.h:88
otb::ConfusionMatrixToMassOfBelief::GetMapOfIndices
MapOfIndicesType GetMapOfIndices() const
Definition: otbConfusionMatrixToMassOfBelief.h:133
otb::ConfusionMatrixToMassOfBelief::m_DefinitionMethod
MassOfBeliefDefinitionMethod m_DefinitionMethod
Definition: otbConfusionMatrixToMassOfBelief.h:165
otb::ConfusionMatrixToMassOfBelief::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbConfusionMatrixToMassOfBelief.h:62
otb::ConfusionMatrixToMassOfBelief::Superclass
itk::ProcessObject Superclass
Definition: otbConfusionMatrixToMassOfBelief.h:60
otb::ConfusionMatrixToMassOfBelief::GetMapOfClasses
MapOfClassesType GetMapOfClasses() const
Definition: otbConfusionMatrixToMassOfBelief.h:114
otb::ConfusionMatrixToMassOfBelief::ConfusionMatrixMeasurementsType
otb::ConfusionMatrixMeasurements< ConfusionMatrixType, ClassLabelType > ConfusionMatrixMeasurementsType
Definition: otbConfusionMatrixToMassOfBelief.h:78
otb::ConfusionMatrixToMassOfBelief::m_MapOfClasses
MapOfClassesType m_MapOfClasses
Definition: otbConfusionMatrixToMassOfBelief.h:162
otb::ConfusionMatrixToMassOfBelief::Self
ConfusionMatrixToMassOfBelief Self
Definition: otbConfusionMatrixToMassOfBelief.h:59
otb::ConfusionMatrixMeasurements::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbConfusionMatrixMeasurements.h:59
otb::ConfusionMatrixToMassOfBelief::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbConfusionMatrixToMassOfBelief.h:61
otb::ConfusionMatrixToMassOfBelief::m_MapMassOfBelief
LabelMassMapType m_MapMassOfBelief
Definition: otbConfusionMatrixToMassOfBelief.h:166