OTB  10.0.0
Orfeo Toolbox
otbLabelMapClassifier.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 otbLabelMapClassifier_h
22 #define otbLabelMapClassifier_h
23 
24 #include "itkInPlaceLabelMapFilter.h"
26 #include "itkListSample.h"
28 
29 namespace otb
30 {
31 
41 template <class TInputLabelMap>
42 class ITK_EXPORT LabelMapClassifier : public itk::InPlaceLabelMapFilter<TInputLabelMap>
43 {
44 public:
47  typedef itk::InPlaceLabelMapFilter<TInputLabelMap> Superclass;
48  typedef itk::SmartPointer<Self> Pointer;
49  typedef itk::SmartPointer<const Self> ConstPointer;
50 
52  typedef TInputLabelMap LabelMapType;
53  typedef typename LabelMapType::Pointer LabelMapPointer;
54  typedef typename LabelMapType::ConstPointer LabelMaponstPointer;
55  typedef typename LabelMapType::LabelObjectType LabelObjectType;
56 
57  typedef typename LabelObjectType::AttributesValueType AttributesValueType;
58  typedef typename LabelObjectType::ClassLabelType ClassLabelType;
59 
61  itkStaticConstMacro(InputImageDimension, unsigned int, TInputLabelMap::ImageDimension);
62 
65  typedef typename ModelType::Pointer ModelPointer;
68 
70  itkNewMacro(Self);
71 
73  itkTypeMacro(LabelMapClassifier, itk::InPlaceLabelMapFilter);
74 
75  itkSetObjectMacro(Model, ModelType);
76 
78  {
79  m_MeasurementFunctor = functor;
80  }
81 
83  {
84  return m_MeasurementFunctor;
85  }
86 
87 protected:
89  ~LabelMapClassifier() override = default;
90 
91  void ThreadedProcessLabelObject(LabelObjectType* labelObject) override;
92 
93  void ReleaseInputs() override;
94 
95 
96 private:
97  LabelMapClassifier(const Self&) = delete;
98  void operator=(const Self&) = delete;
99 
102 
105 
106 }; // end of class
107 
108 } // end namespace otb
109 
110 #ifndef OTB_MANUAL_INSTANTIATION
111 #include "otbLabelMapClassifier.hxx"
112 #endif
113 
114 #endif
Classify each LabelObject of the input LabelMap in place.
LabelMapType::LabelObjectType LabelObjectType
MeasurementFunctorType m_MeasurementFunctor
MachineLearningModel< AttributesValueType, ClassLabelType > ModelType
LabelObjectType::AttributesValueType AttributesValueType
LabelMapType::Pointer LabelMapPointer
LabelMapType::ConstPointer LabelMaponstPointer
Functor::AttributesMapMeasurementFunctor< LabelObjectType, MeasurementVectorType > MeasurementFunctorType
itk::SmartPointer< const Self > ConstPointer
LabelObjectType::ClassLabelType ClassLabelType
itk::SmartPointer< Self > Pointer
void operator=(const Self &)=delete
void SetMeasurementFunctor(const MeasurementFunctorType &functor)
ModelType::InputSampleType MeasurementVectorType
ModelType::Pointer ModelPointer
MeasurementFunctorType & GetMeasurementFunctor()
~LabelMapClassifier() override=default
LabelMapClassifier(const Self &)=delete
itk::InPlaceLabelMapFilter< TInputLabelMap > Superclass
MachineLearningModel is the base class for all classifier objects (SVM, KNN, Random Forests,...
itk::SmartPointer< Self > Pointer
MLMSampleTraits< TInputValue >::SampleType InputSampleType
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.