OTB  10.0.0
Orfeo Toolbox
otbLabelMapToSampleListFilter.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 #ifndef otbLabelMapToSampleListFilter_h
22 #define otbLabelMapToSampleListFilter_h
23 
24 #include <algorithm>
25 
26 #include "itkProcessObject.h"
28 
29 namespace otb
30 {
43 template <class TInputLabelMap, class TOutputSampleList,
44  class TMeasurementFunctor =
45  Functor::AttributesMapMeasurementFunctor<typename TInputLabelMap::LabelObjectType, typename TOutputSampleList::MeasurementVectorType>>
46 class ITK_EXPORT LabelMapToSampleListFilter : public itk::ProcessObject
47 {
48 public:
51  typedef itk::ProcessObject Superclass;
52  typedef itk::SmartPointer<Self> Pointer;
53  typedef itk::SmartPointer<const Self> ConstPointer;
54 
56  itkNewMacro(Self);
57 
59  itkTypeMacro(LabelMapToSampleListFilter, ProcessObject);
60 
62  typedef TInputLabelMap InputLabelMapType;
63  typedef typename InputLabelMapType::ConstPointer InputLabelMapConstPointerType;
64  typedef typename InputLabelMapType::LabelObjectType LabelObjectType;
65 
66  typedef typename InputLabelMapType::ConstIterator ConstIteratorType;
67 
68  typedef TOutputSampleList OutputSampleListType;
69  typedef typename OutputSampleListType::Pointer OutputSampleListPointerType;
70  typedef typename OutputSampleListType::MeasurementVectorType MeasurementVectorType;
71 
72  typedef TMeasurementFunctor MeasurementFunctorType;
73 
75  typedef typename Superclass::DataObjectPointer DataObjectPointerType;
76  typedef itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType;
77 
79  void SetInputLabelMap(const InputLabelMapType* inputLabelMap);
80  const InputLabelMapType* GetInputLabelMap() const;
82 
84  const OutputSampleListType* GetOutputSampleList();
85 
88  {
89  m_MeasurementFunctor = functor;
90  }
91 
93  {
94  return m_MeasurementFunctor;
95  }
96 
97 protected:
99  ~LabelMapToSampleListFilter() override;
100 
101  void GenerateData() override;
102 
104  DataObjectPointerType MakeOutput(DataObjectPointerArraySizeType idx) override;
105  using Superclass::MakeOutput;
106 
107  void PrintSelf(std::ostream& os, itk::Indent indent) const override;
108 
109 private:
111  void operator=(const Self&) = delete;
112 
115 };
116 
117 } // end namespace otb
118 
119 #ifndef OTB_MANUAL_INSTANTIATION
121 #endif
122 
123 #endif
This class converts a LabelObjectMap to a SampleList for learning and classification.
void SetMeasurementFunctor(const MeasurementFunctorType &functor)
InputLabelMapType::LabelObjectType LabelObjectType
void operator=(const Self &)=delete
itk::SmartPointer< const Self > ConstPointer
itk::ProcessObject::DataObjectPointerArraySizeType DataObjectPointerArraySizeType
Superclass::DataObjectPointer DataObjectPointerType
InputLabelMapType::ConstPointer InputLabelMapConstPointerType
InputLabelMapType::ConstIterator ConstIteratorType
MeasurementFunctorType & GetMeasurementFunctor()
LabelMapToSampleListFilter(const Self &)=delete
OutputSampleListType::MeasurementVectorType MeasurementVectorType
OutputSampleListType::Pointer OutputSampleListPointerType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.