OTB  9.0.0
Orfeo Toolbox
otbHistogramStatisticsFunction.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 
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
otb::HistogramStatisticsFunction::GetEntropy
OutputType GetEntropy()
Definition: otbHistogramStatisticsFunction.hxx:37
otb::HistogramStatisticsFunction::FrequencyType
TInputHistogram::AbsoluteFrequencyType FrequencyType
Definition: otbHistogramStatisticsFunction.h:54
otb::HistogramStatisticsFunction::ConstPointer
itk::SmartPointer< const Self > ConstPointer
Definition: otbHistogramStatisticsFunction.h:51
otb::HistogramStatisticsFunction::SetInputHistogram
void SetInputHistogram(const TInputHistogram *histogram)
Definition: otbHistogramStatisticsFunction.h:75
otb::HistogramStatisticsFunction::Pointer
itk::SmartPointer< Self > Pointer
Definition: otbHistogramStatisticsFunction.h:50
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::HistogramStatisticsFunction::m_covariance
OutputType m_covariance
Definition: otbHistogramStatisticsFunction.h:115
otb::HistogramStatisticsFunction::CalculateEntropy
void CalculateEntropy()
Definition: otbHistogramStatisticsFunction.hxx:67
otb::HistogramStatisticsFunction::MeasurementType
TInputHistogram::MeasurementType MeasurementType
Definition: otbHistogramStatisticsFunction.h:53
otb::HistogramStatisticsFunction::RealType
itk::NumericTraits< MeasurementType >::RealType RealType
Definition: otbHistogramStatisticsFunction.h:55
otb::HistogramStatisticsFunction::OutputType
std::vector< TOutput > OutputType
Definition: otbHistogramStatisticsFunction.h:59
otb::HistogramStatisticsFunction::Compute
void Compute() override
Definition: otbHistogramStatisticsFunction.h:87
otbHistogramStatisticsFunction.hxx
otb::HistogramStatisticsFunction::Superclass
itk::HistogramAlgorithmBase< TInputHistogram > Superclass
Definition: otbHistogramStatisticsFunction.h:49
otb::HistogramStatisticsFunction::Self
HistogramStatisticsFunction Self
Definition: otbHistogramStatisticsFunction.h:48
otb::HistogramStatisticsFunction::PrintSelf
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Definition: otbHistogramStatisticsFunction.hxx:173
otb::HistogramStatisticsFunction
Computes parameters for a histogram.
Definition: otbHistogramStatisticsFunction.h:44
otb::HistogramStatisticsFunction::m_entropy
OutputType m_entropy
Definition: otbHistogramStatisticsFunction.h:113
otb::HistogramStatisticsFunction::CalculateMean
void CalculateMean()
Definition: otbHistogramStatisticsFunction.hxx:95
otb::HistogramStatisticsFunction::CalculateCovariance
void CalculateCovariance()
Definition: otbHistogramStatisticsFunction.hxx:127
otb::HistogramStatisticsFunction::m_InputHistogram
TInputHistogram::ConstPointer m_InputHistogram
Definition: otbHistogramStatisticsFunction.h:119
otb::HistogramStatisticsFunction::~HistogramStatisticsFunction
~HistogramStatisticsFunction() override
Definition: otbHistogramStatisticsFunction.h:94
otb::HistogramStatisticsFunction::GenerateData
void GenerateData()
Definition: otbHistogramStatisticsFunction.hxx:163
otb::HistogramStatisticsFunction::HistogramStatisticsFunction
HistogramStatisticsFunction()
Definition: otbHistogramStatisticsFunction.hxx:31
otb::HistogramStatisticsFunction::m_IsModified
bool m_IsModified
Definition: otbHistogramStatisticsFunction.h:116
otb::HistogramStatisticsFunction::GetMean
OutputType GetMean()
Definition: otbHistogramStatisticsFunction.hxx:47
otb::HistogramStatisticsFunction::GetCovariance
OutputType GetCovariance()
Definition: otbHistogramStatisticsFunction.hxx:57
otb::HistogramStatisticsFunction::m_mean
OutputType m_mean
Definition: otbHistogramStatisticsFunction.h:114