OTB  9.0.0
Orfeo Toolbox
otbGeodesicMorphologyDecompositionImageFilter.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 otbGeodesicMorphologyDecompositionImageFilter_hxx
22 #define otbGeodesicMorphologyDecompositionImageFilter_hxx
23 
25 
26 namespace otb
27 {
31 template <class TInputImage, class TOutputImage, class TStructuringElement>
33 {
34  this->SetNumberOfRequiredOutputs(3);
35  this->SetNthOutput(0, OutputImageType::New());
36  this->SetNthOutput(1, OutputImageType::New());
37  this->SetNthOutput(2, OutputImageType::New());
39 
40  m_Radius.Fill(1);
41 
42  // Create a process accumulator for tracking the progress of minipipeline
43  m_Progress = itk::ProgressAccumulator::New();
44  m_Progress->SetMiniPipelineFilter(this);
45 
46  m_OpeningFilter = OpeningFilterType::New();
47  m_ClosingFilter = ClosingFilterType::New();
48  m_LevelingFilter = LevelingFilterType::New();
49  m_ConvexFilter = ConvexFilterType::New();
50  m_ConcaveFilter = ConcaveFilterType::New();
51 
52  // Register Internal Filter for progress
53  m_Progress->RegisterInternalFilter(m_OpeningFilter, 0.2);
54  m_Progress->RegisterInternalFilter(m_ClosingFilter, 0.2);
55  m_Progress->RegisterInternalFilter(m_LevelingFilter, 0.2);
56  m_Progress->RegisterInternalFilter(m_ConvexFilter, 0.2);
57  m_Progress->RegisterInternalFilter(m_ConcaveFilter, 0.2);
58 
59 
60  m_FullyConnected = true;
61  m_PreserveIntensities = true;
62 }
66 template <class TInputImage, class TOutputImage, class TStructuringElement>
68 {
69  StructuringElementType se;
70  se.SetRadius(m_Radius);
71  se.CreateStructuringElement();
73 
74  m_OpeningFilter->SetInput(this->GetInput());
75  m_OpeningFilter->SetKernel(se);
76  m_OpeningFilter->SetPreserveIntensities(m_PreserveIntensities);
77  m_OpeningFilter->SetFullyConnected(m_FullyConnected);
78 
79  m_ClosingFilter->SetInput(this->GetInput());
80  m_ClosingFilter->SetKernel(se);
81  m_ClosingFilter->SetPreserveIntensities(m_PreserveIntensities);
82  m_ClosingFilter->SetFullyConnected(m_FullyConnected);
83 
84  m_ConvexFilter->SetInput1(this->GetInput());
85  m_ConvexFilter->SetInput2(m_OpeningFilter->GetOutput());
86 
87  m_ConcaveFilter->SetInput1(m_ClosingFilter->GetOutput());
88  m_ConcaveFilter->SetInput2(this->GetInput());
89 
90  using namespace otb::Functor::LevelingFunctor_tags;
91  // Template keyword mandatory to avoid parsing error when using
92  // template methods within template code
93  m_LevelingFilter->template SetInput<pixel>(this->GetInput());
94  m_LevelingFilter->template SetInput<convex_pixel>(m_ConvexFilter->GetOutput());
95  m_LevelingFilter->template SetInput<concave_pixel>(m_ConcaveFilter->GetOutput());
96 
97  m_ConvexFilter->GraftOutput(this->GetConvexMap());
98  m_ConvexFilter->Update();
99  this->GraftNthOutput(1, m_ConvexFilter->GetOutput());
100 
101  m_ConcaveFilter->GraftOutput(this->GetConcaveMap());
102  m_ConcaveFilter->Update();
103  this->GraftNthOutput(2, m_ConcaveFilter->GetOutput());
104 
105  m_LevelingFilter->GraftOutput(this->GetOutput());
106  m_LevelingFilter->Update();
107  this->GraftOutput(m_LevelingFilter->GetOutput());
108 }
109 
113 template <class TInputImage, class TOutputImage, class TStructuringElement>
115 {
116  if (this->GetNumberOfOutputs() < 2)
117  {
118  return nullptr;
119  }
120  return static_cast<OutputImageType*>(this->itk::ProcessObject::GetOutput(1));
121 }
123 
127 template <class TInputImage, class TOutputImage, class TStructuringElement>
129 {
130  if (this->GetNumberOfOutputs() < 3)
131  {
132  return nullptr;
133  }
134  return static_cast<OutputImageType*>(this->itk::ProcessObject::GetOutput(2));
135 }
137 
otb
The "otb" namespace contains all Orfeo Toolbox (OTB) classes.
Definition: otbJoinContainer.h:32
otb::GeodesicMorphologyDecompositionImageFilter::GenerateData
void GenerateData(void) override
otb::GeodesicMorphologyDecompositionImageFilter::GetConcaveMap
OutputImageType * GetConcaveMap(void)
otb::GeodesicMorphologyDecompositionImageFilter::GetConvexMap
OutputImageType * GetConvexMap(void)
otb::Functor::LevelingFunctor_tags
Definition: otbGeodesicMorphologyLevelingFilter.h:30
otbGeodesicMorphologyDecompositionImageFilter.h
otb::GeodesicMorphologyDecompositionImageFilter::GeodesicMorphologyDecompositionImageFilter
GeodesicMorphologyDecompositionImageFilter()