OTB  10.0.0
Orfeo Toolbox
otbPathListToHistogramGenerator.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 otbPathListToHistogramGenerator_h
23 #define otbPathListToHistogramGenerator_h
24 
25 #include "itkSampleToHistogramFilter.h"
26 #include "itkHistogram.h"
27 #include "itkListSample.h"
28 #include "itkVector.h"
29 #include "otbObjectList.h"
30 
31 // TODO : write a HistogramSource when outputting Histogram
32 
33 namespace otb
34 {
35 
48 template <class TPath, class TFunction>
49 class PathListToHistogramGenerator : public itk::ProcessObject
50 {
51 public:
54  typedef itk::ProcessObject Superclass;
55  typedef itk::SmartPointer<Self> Pointer;
56  typedef itk::SmartPointer<const Self> ConstPointer;
57 
59  itkTypeMacro(PathListToHistogramGenerator, itk::ProcessObject);
60 
62  itkNewMacro(Self);
63 
64  typedef TPath PathType;
65  typedef typename PathType::Pointer PathPointer;
67 
68  typedef TFunction FunctionType;
69 
70  typedef typename TFunction::OutputType RealType;
71 
73  typedef itk::Vector<MeasurementType, 1> ListSampleVectorType;
74  typedef itk::Statistics::ListSample<ListSampleVectorType> ListSampleType;
75  typedef typename ListSampleType::Pointer ListSamplePointer;
76  typedef typename ListSampleType::ConstPointer ListSampleConstPointer;
77 
78  typedef itk::Statistics::DenseFrequencyContainer2 FrequencyContainerType;
79  typedef itk::Statistics::Histogram<MeasurementType, FrequencyContainerType> HistogramType;
80 
81  typedef itk::Statistics::SampleToHistogramFilter<ListSampleType, HistogramType> GeneratorType;
82  typedef typename GeneratorType::Pointer GeneratorPointer;
83 
84  typedef typename HistogramType::Pointer HistogramPointer;
85  typedef typename HistogramType::ConstPointer HistogramConstPointer;
86  typedef typename HistogramType::SizeType SizeType;
87  typedef typename HistogramType::MeasurementVectorType MeasurementVectorType;
88 
90  typedef typename Superclass::DataObjectPointer DataObjectPointer;
91  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
92 
93  void GraftNthOutput(unsigned int idx, itk::DataObject* graft);
94  void GraftOutput(itk::DataObject* graft);
95 
96 public:
98  using Superclass::SetInput;
99  void SetInput(const PathListType* path);
100  const PathListType* GetInput() const;
102 
103  // Return the output histogram.
104  const HistogramType* GetOutput() const;
105 
107  void SetNumberOfBins(const SizeType& size);
108 
110  void SetMarginalScale(double marginalScale);
111  void SetHistogramMin(const MeasurementVectorType& histogramMin);
112  void SetHistogramMax(const MeasurementVectorType& histogramMax);
113  void SetAutoMinMax(bool autoMinMax);
115 
116 protected:
119  {
120  }
121  void GenerateData() override;
123  using Superclass::MakeOutput;
124 
125  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
126 
127 private:
129 };
130 
131 } // end of namespace OTB
132 
133 #ifndef OTB_MANUAL_INSTANTIATION
135 #endif
136 
137 #endif
This class is a generic all-purpose wrapping around an std::vector<itk::SmartPointer<ObjectType> >.
Definition: otbObjectList.h:41
This class generates an histogram from a list of path.
void GraftNthOutput(unsigned int idx, itk::DataObject *graft)
void SetHistogramMax(const MeasurementVectorType &histogramMax)
itk::SmartPointer< const Self > ConstPointer
itk::Statistics::SampleToHistogramFilter< ListSampleType, HistogramType > GeneratorType
ListSampleType::ConstPointer ListSampleConstPointer
itk::Statistics::DenseFrequencyContainer2 FrequencyContainerType
void PrintSelf(std::ostream &os, itk::Indent indent) const override
HistogramType::MeasurementVectorType MeasurementVectorType
itk::Vector< MeasurementType, 1 > ListSampleVectorType
itk::Statistics::Histogram< MeasurementType, FrequencyContainerType > HistogramType
itk::Statistics::ListSample< ListSampleVectorType > ListSampleType
DataObjectPointer MakeOutput(DataObjectPointerArraySizeType) override
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
void SetHistogramMin(const MeasurementVectorType &histogramMin)
Superclass::DataObjectPointer DataObjectPointer
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.