OTB  6.7.0
Orfeo Toolbox
otbSamplingRateCalculator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2019 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
41  : public itk::Object
42 {
43 public:
49 
51  typedef std::map<std::string, unsigned long> ClassCountMapType;
52  typedef ClassCountMapType::const_iterator constItMapType;
53  typedef struct OTBSampling_EXPORT Triplet
54  {
55  unsigned long Required;
56  unsigned long Tot;
57  double Rate;
58  bool operator==(const struct Triplet & triplet) const;
59  } TripletType;
60 
61  typedef std::map<std::string, TripletType > MapRateType;
62 
64  itkNewMacro(Self);
65 
67  itkTypeMacro(SamplingRateCalculator, itk::Object);
68 
70  void SetNbOfSamplesByClass(const ClassCountMapType &required);
71 
73  void SetNbOfSamplesAllClasses(unsigned long);
74 
76  void SetPercentageOfSamples(double percent);
77 
79  void SetTotalNumberOfSamples(unsigned long value);
80 
83  void SetMinimumNbOfSamplesByClass(void);
84 
86  void SetAllSamples(void);
87 
90  void Write(std::string filename);
91 
94  void Read(std::string filename);
95 
97  itkGetConstReferenceMacro(RatesByClass,MapRateType);
98 
102  void SetClassCount(const ClassCountMapType& map);
103 
105  void ClearRates(void);
106 
107  static ClassCountMapType ReadRequiredSamples(const std::string& filename);
108 
109 protected:
112 
115 
117  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
118 
119 private:
120  SamplingRateCalculator(const Self &) = delete;
121  void operator =(const Self&) = delete;
122 
124  void UpdateRate(const std::string &name);
125 
128 };
129 } // End namespace otb
130 
131 #endif
itk::SmartPointer< const Self > ConstPointer
OTBApplicationEngine_EXPORT int Read(const std::string &filename, Application::Pointer application)
OTBGdalAdapters_EXPORT bool operator==(const CoordinateTransformation &ct1, const CoordinateTransformation &ct2) noexcept
equal operator
itk::SmartPointer< Self > Pointer
std::map< std::string, unsigned long > ClassCountMapType
std::map< std::string, TripletType > MapRateType
struct OTBSampling_EXPORT otb::SamplingRateCalculator::Triplet TripletType
OTBApplicationEngine_EXPORT void Write(const std::string &filename, Application::Pointer application)
This class is a sampling rate calculator.
ClassCountMapType::const_iterator constItMapType