OTB  10.0.0
Orfeo Toolbox
otbContingencyTableCalculator.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 otbContingencyTableCalculator_h
22 #define otbContingencyTableCalculator_h
23 
24 #include "itkObject.h"
25 #include "itkObjectFactory.h"
26 #include "otbContingencyTable.h"
27 #include <map>
28 
29 namespace otb
30 {
40 template <class TClassLabel>
41 class ITK_EXPORT ContingencyTableCalculator : public itk::Object
42 {
43 public:
44 
47  typedef itk::Object Superclass;
48  typedef itk::SmartPointer<Self> Pointer;
49  typedef itk::SmartPointer<const Self> ConstPointer;
50 
52  itkTypeMacro(ContingencyTableCalculator, itk::Object);
53 
55  itkNewMacro(Self);
56 
59 
60  typedef typename std::map<TClassLabel, unsigned long> CountMapType;
61  typedef typename std::map<TClassLabel, CountMapType> MapOfClassesType;
62 
67  template <class TRefIterator, class TProdIterator>
68  void Compute(TRefIterator itRef, TProdIterator itProd, bool refHasNoData = false, typename TRefIterator::InternalPixelType refNoData = 0,
69  bool prodHasNoData = false, typename TProdIterator::InternalPixelType prodNoData = 0);
70 
75  template <class TRefIterator, class TProdIterator>
76  void Compute(TRefIterator refBegin, TRefIterator refEnd, TProdIterator prodBegin, TProdIterator prodEnd);
77 
78  itkGetConstMacro(NumberOfRefClasses, unsigned long);
79  itkGetConstMacro(NumberOfProdClasses, unsigned long);
80  itkGetConstMacro(NumberOfSamples, unsigned long);
81 
82  void Clear();
83  ContingencyTablePointerType BuildContingencyTable();
84 
85 protected:
88  {
89  }
90  // void PrintSelf(std::ostream& os, itk::Indent indent) const override;
91 
92 private:
93  ContingencyTableCalculator(const Self&) = delete;
94  void operator=(const Self&) = delete;
95 
97  unsigned long m_NumberOfRefClasses;
98  unsigned long m_NumberOfProdClasses;
99  unsigned long m_NumberOfSamples;
100 };
101 }
102 
103 #ifndef OTB_MANUAL_INSTANTIATION
105 #endif
106 
107 #endif // otbContingencyTableCalculator_h
ContingencyTableCalculator provide facilities to compute ContingencyTable.
ContingencyTable< TClassLabel > ContingencyTableType
std::map< TClassLabel, unsigned long > CountMapType
ContingencyTableType::Pointer ContingencyTablePointerType
std::map< TClassLabel, CountMapType > MapOfClassesType
ContingencyTableCalculator(const Self &)=delete
void operator=(const Self &)=delete
itk::SmartPointer< const Self > ConstPointer
itk::SmartPointer< Self > Pointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.