OTB  9.0.0
Orfeo Toolbox
otbSamplingRateCalculator.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 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 
69  void SetNbOfSamplesByClass(const ClassCountMapType& required);
70 
72  void SetNbOfSamplesAllClasses(unsigned long);
73 
75  void SetPercentageOfSamples(double percent);
76 
78  void SetTotalNumberOfSamples(unsigned long value);
79 
82  void SetMinimumNbOfSamplesByClass(void);
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 
101  void SetClassCount(const ClassCountMapType& map);
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
otb::SamplingRateCalculator::constItMapType
ClassCountMapType::const_iterator constItMapType
Definition: otbSamplingRateCalculator.h:51
otb::SamplingRateCalculator::Triplet::Tot
unsigned long Tot
Definition: otbSamplingRateCalculator.h:55
otb::SamplingRateCalculator::Triplet::Required
unsigned long Required
Definition: otbSamplingRateCalculator.h:54
otb::Wrapper::XML::Write
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::SamplingRateCalculator::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbSamplingRateCalculator.h:47
otb::operator==
constexpr bool operator==(extents< StaticExtentsL... > const &lhs, extents< StaticExtentsR... > const &rhs)
Definition: otbExtents.h:150
otb::SamplingRateCalculator::TripletType
struct OTBSampling_EXPORT otb::SamplingRateCalculator::Triplet TripletType
otb::SamplingRateCalculator::MapRateType
std::map< std::string, TripletType > MapRateType
Definition: otbSamplingRateCalculator.h:60
otb::SamplingRateCalculator
This class is a sampling rate calculator.
Definition: otbSamplingRateCalculator.h:40
otb::SamplingRateCalculator::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbSamplingRateCalculator.h:46
otb::SamplingRateCalculator::m_RatesByClass
MapRateType m_RatesByClass
Definition: otbSamplingRateCalculator.h:128
otb::SamplingRateCalculator::ClassCountMapType
std::map< std::string, unsigned long > ClassCountMapType
Definition: otbSamplingRateCalculator.h:50
otb::Wrapper::XML::Read
OTBApplicationEngine_EXPORT int Read(const std::string &filename, Application::Pointer application)
otb::SamplingRateCalculator::~SamplingRateCalculator
~SamplingRateCalculator() override
Definition: otbSamplingRateCalculator.h:113
otb::SamplingRateCalculator::Self
SamplingRateCalculator Self
Definition: otbSamplingRateCalculator.h:44
otb::SamplingRateCalculator::Triplet::Rate
double Rate
Definition: otbSamplingRateCalculator.h:56
otb::SamplingRateCalculator::Triplet
Definition: otbSamplingRateCalculator.h:52
otb::SamplingRateCalculator::Superclass
itk::Object Superclass
Definition: otbSamplingRateCalculator.h:45