OTB  10.0.0
Orfeo Toolbox
otbHistogramStatisticsFunction.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 
22 #ifndef otbHistogramStatisticsFunction_h
23 #define otbHistogramStatisticsFunction_h
24 
25 #include "itkNumericTraits.h"
26 #include "itkHistogramAlgorithmBase.h"
27 
28 namespace otb
29 {
30 
43 template <class TInputHistogram, class TOutput>
44 class HistogramStatisticsFunction : public itk::HistogramAlgorithmBase<TInputHistogram>
45 {
46 public:
49  typedef itk::HistogramAlgorithmBase<TInputHistogram> Superclass;
50  typedef itk::SmartPointer<Self> Pointer;
51  typedef itk::SmartPointer<const Self> ConstPointer;
52 
53  typedef typename TInputHistogram::MeasurementType MeasurementType;
54  typedef typename TInputHistogram::AbsoluteFrequencyType FrequencyType; // FIXME several possibilities in the new framework
55  typedef typename itk::NumericTraits<MeasurementType>::RealType RealType;
56 
58  itkTypeMacro(HistogramStatisticsFunction, HistogramAlgorithmsBase);
59  itkNewMacro(Self);
61 
63  typedef std::vector<TOutput> OutputType;
64 
67 
70 
73 
75  void SetInputHistogram(const TInputHistogram* histogram)
76  {
77  if (m_InputHistogram != histogram)
78  {
79  m_InputHistogram = histogram;
80  this->Modified();
81  m_IsModified = true;
82  }
83  }
85 
87  void Compute() override
88  {
89  this->GenerateData();
90  }
91 
92 protected:
95  {
96  }
97  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
98 
100  void GenerateData();
101 
103  void CalculateEntropy();
104 
106  void CalculateMean();
107 
109  void CalculateCovariance();
110 
111 
112 private:
117 
119  typename TInputHistogram::ConstPointer m_InputHistogram;
120 
121 }; // end of class
122 
123 } // end of namespace otb
124 
125 #ifndef OTB_MANUAL_INSTANTIATION
127 #endif
128 
129 #endif
Computes parameters for a histogram.
itk::HistogramAlgorithmBase< TInputHistogram > Superclass
void SetInputHistogram(const TInputHistogram *histogram)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
itk::SmartPointer< const Self > ConstPointer
itk::NumericTraits< MeasurementType >::RealType RealType
TInputHistogram::MeasurementType MeasurementType
TInputHistogram::ConstPointer m_InputHistogram
TInputHistogram::AbsoluteFrequencyType FrequencyType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.