OTB  10.0.0
Orfeo Toolbox
otbSamplingRateCalculator.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 otbSamplingRateCalculator_h
22 #define otbSamplingRateCalculator_h
23 
24 #include "itkImageRegion.h"
25 #include "itkVectorContainer.h"
26 #include <set>
27 #include "OTBSamplingExport.h"
28 
29 namespace otb
30 {
40 class OTBSampling_EXPORT SamplingRateCalculator : public itk::Object
41 {
42 public:
45  typedef itk::Object Superclass;
46  typedef itk::SmartPointer<Self> Pointer;
47  typedef itk::SmartPointer<const Self> ConstPointer;
48 
50  typedef std::map<std::string, unsigned long> ClassCountMapType;
51  typedef ClassCountMapType::const_iterator constItMapType;
52  typedef struct OTBSampling_EXPORT Triplet
53  {
54  unsigned long Required;
55  unsigned long Tot;
56  double Rate;
57  bool operator==(const struct Triplet& triplet) const;
58  } TripletType;
59 
60  typedef std::map<std::string, TripletType> MapRateType;
61 
63  itkNewMacro(Self);
64 
66  itkTypeMacro(SamplingRateCalculator, itk::Object);
67 
70 
72  void SetNbOfSamplesAllClasses(unsigned long);
73 
75  void SetPercentageOfSamples(double percent);
76 
78  void SetTotalNumberOfSamples(unsigned long value);
79 
83 
85  void SetAllSamples(void);
86 
89  void Write(std::string filename);
90 
93  void Read(std::string filename);
94 
96  itkGetConstReferenceMacro(RatesByClass, MapRateType);
97 
102 
104  void ClearRates(void);
105 
106  static ClassCountMapType ReadRequiredSamples(const std::string& filename);
107 
108 protected:
111 
114  {
115  }
116 
118  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
119 
120 private:
121  SamplingRateCalculator(const Self&) = delete;
122  void operator=(const Self&) = delete;
123 
125  void UpdateRate(const std::string& name);
126 
129 };
130 } // End namespace otb
131 
132 #endif
This class is a sampling rate calculator.
void SetMinimumNbOfSamplesByClass(void)
void Read(std::string filename)
std::map< std::string, unsigned long > ClassCountMapType
void SetTotalNumberOfSamples(unsigned long value)
void operator=(const Self &)=delete
itk::SmartPointer< const Self > ConstPointer
void UpdateRate(const std::string &name)
SamplingRateCalculator(const Self &)=delete
void SetNbOfSamplesAllClasses(unsigned long)
static ClassCountMapType ReadRequiredSamples(const std::string &filename)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
std::map< std::string, TripletType > MapRateType
void SetNbOfSamplesByClass(const ClassCountMapType &required)
void SetClassCount(const ClassCountMapType &map)
ClassCountMapType::const_iterator constItMapType
void Write(std::string filename)
void SetPercentageOfSamples(double percent)
itk::SmartPointer< Self > Pointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
bool operator==(const struct Triplet &triplet) const