OTB  9.0.0
Orfeo Toolbox
otbLabelMapClassifier.hxx
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 #ifndef otbLabelMapClassifier_hxx
22 #define otbLabelMapClassifier_hxx
23 
24 #include "otbLabelMapClassifier.h"
25 
26 
27 namespace otb
28 {
29 
30 template <class TInputImage>
32 {
33  // Force to single-threaded in case the learning model is not thread safe
34  // This way, we benefit of the LabelMapFilter design and only need
35  // to implement ThreadedProcessLabelObject
36  this->SetNumberOfThreads(1); // TODO : check if still needed
37 }
38 
39 template <class TInputImage>
41 {
42  // by pass itk::InPlaceLabelMapFilter::ReleaseInputs() implementation,
43  // which caused memory issue when ran inplace
44  this->itk::LabelMapFilter<TInputImage, TInputImage>::ReleaseInputs();
45 }
46 
47 template <class TInputImage>
49 {
50  ClassLabelType classLabel = (m_Model->Predict(m_MeasurementFunctor(labelObject)))[0];
51  labelObject->SetClassLabel(classLabel);
52 }
53 
54 } // end namespace otb
55 #endif
otb::LabelMapClassifier::ClassLabelType
LabelObjectType::ClassLabelType ClassLabelType
Definition: otbLabelMapClassifier.h:58
otb::LabelMapClassifier::LabelObjectType
LabelMapType::LabelObjectType LabelObjectType
Definition: otbLabelMapClassifier.h:55
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::LabelMapClassifier::ThreadedProcessLabelObject
void ThreadedProcessLabelObject(LabelObjectType *labelObject) override
Definition: otbLabelMapClassifier.hxx:48
otb::LabelMapClassifier::ReleaseInputs
void ReleaseInputs() override
Definition: otbLabelMapClassifier.hxx:40
otb::LabelMapClassifier::LabelMapClassifier
LabelMapClassifier()
Definition: otbLabelMapClassifier.hxx:31
otbLabelMapClassifier.h