OTB  9.0.0
Orfeo Toolbox
otbMorphologicalProfilesSegmentationFilter.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 otbMorphologicalProfilesSegmentationFilter_hxx
22 #define otbMorphologicalProfilesSegmentationFilter_hxx
23 
25 
26 namespace otb
27 {
28 
29 template <class TInputImage, class TOutputImage, class TInternalPrecision, class TStructuringElement>
31 {
32  m_ProfileSize = 5;
33  m_ProfileStart = 1;
34  m_ProfileStep = 1;
35  m_Sigma = 0.0;
36 
37  m_ClassificationFilter = MultiScaleClassificationFilterType::New();
38  m_ConnectedComponentsFilter = ConnectedComponentsFilterType::New();
39  m_OpeningProfile = OpeningProfileFilterType::New();
40  m_ClosingProfile = ClosingProfileFilterType::New();
41  m_OpeningDerivativeProfile = DerivativeFilterType::New();
42  m_ClosingDerivativeProfile = DerivativeFilterType::New();
43  m_OpeningCharacteristicsFilter = MultiScaleCharacteristicsFilterType::New();
44  m_ClosingCharacteristicsFilter = MultiScaleCharacteristicsFilterType::New();
45  // Wire pipeline
46  m_OpeningDerivativeProfile->SetInput(m_OpeningProfile->GetOutput());
47  m_ClosingDerivativeProfile->SetInput(m_ClosingProfile->GetOutput());
48  m_OpeningCharacteristicsFilter->SetInput(m_OpeningDerivativeProfile->GetOutput());
49  m_ClosingCharacteristicsFilter->SetInput(m_ClosingDerivativeProfile->GetOutput());
50 
51  using namespace Functor::MultiScaleConvexOrConcaveDecisionRule_tags;
52  // Template keyword mandatory to avoid parsing error when using
53  // template methods within template code
54  m_ClassificationFilter->template SetInput<max_opening_profile_derivative>(m_OpeningCharacteristicsFilter->GetOutput());
55  m_ClassificationFilter->template SetInput<opening_profile_characteristics>(m_OpeningCharacteristicsFilter->GetOutputCharacteristics());
56  m_ClassificationFilter->template SetInput<max_closing_profile_derivative>(m_ClosingCharacteristicsFilter->GetOutput());
57  m_ClassificationFilter->template SetInput<closing_profile_characteristics>(m_ClosingCharacteristicsFilter->GetOutputCharacteristics());
58 
59  m_ConnectedComponentsFilter->SetInput(m_ClassificationFilter->GetOutput());
60 }
61 
62 template <class TInputImage, class TOutputImage, class TInternalPrecision, class TStructuringElement>
64 {
65 }
66 
67 template <class TInputImage, class TOutputImage, class TInternalPrecision, class TStructuringElement>
69 {
70  m_OpeningProfile->SetInput(this->GetInput());
71  m_ClosingProfile->SetInput(this->GetInput());
72 
73  m_OpeningProfile->SetProfileSize(m_ProfileSize);
74  m_OpeningProfile->SetInitialValue(m_ProfileStart);
75  m_OpeningProfile->SetStep(m_ProfileStep);
76 
77  m_ClosingProfile->SetProfileSize(m_ProfileSize);
78  m_ClosingProfile->SetInitialValue(m_ProfileStart);
79  m_ClosingProfile->SetStep(m_ProfileStep);
80 
81  m_OpeningCharacteristicsFilter->SetInitialValue(m_ProfileStart);
82  m_OpeningCharacteristicsFilter->SetStep(m_ProfileStep);
83 
84  m_ClosingCharacteristicsFilter->SetInitialValue(m_ProfileStart);
85  m_ClosingCharacteristicsFilter->SetStep(m_ProfileStep);
86 
87  m_ClassificationFilter->GetModifiableFunctor().SetSigma(m_Sigma);
88  m_ClassificationFilter->GetModifiableFunctor().SetLabelSeparator(m_ProfileStart + m_ProfileSize * m_ProfileStep);
89 
90  m_ConnectedComponentsFilter->GraftOutput(this->GetOutput());
91  m_ConnectedComponentsFilter->Update();
92  this->GraftOutput(m_ConnectedComponentsFilter->GetOutput());
93 }
94 }
95 #endif
otbMorphologicalProfilesSegmentationFilter.h
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::MorphologicalProfilesSegmentationFilter::GenerateData
void GenerateData() override
Definition: otbMorphologicalProfilesSegmentationFilter.hxx:68
otb::MorphologicalProfilesSegmentationFilter::~MorphologicalProfilesSegmentationFilter
~MorphologicalProfilesSegmentationFilter() override
Definition: otbMorphologicalProfilesSegmentationFilter.hxx:63
otb::MorphologicalProfilesSegmentationFilter::MorphologicalProfilesSegmentationFilter
MorphologicalProfilesSegmentationFilter()
Definition: otbMorphologicalProfilesSegmentationFilter.hxx:30