21 #ifndef otbGeodesicMorphologyDecompositionImageFilter_hxx
22 #define otbGeodesicMorphologyDecompositionImageFilter_hxx
31 template <
class TInputImage,
class TOutputImage,
class TStructuringElement>
34 this->SetNumberOfRequiredOutputs(3);
35 this->SetNthOutput(0, OutputImageType::New());
36 this->SetNthOutput(1, OutputImageType::New());
37 this->SetNthOutput(2, OutputImageType::New());
43 m_Progress = itk::ProgressAccumulator::New();
44 m_Progress->SetMiniPipelineFilter(
this);
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();
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);
60 m_FullyConnected =
true;
61 m_PreserveIntensities =
true;
66 template <
class TInputImage,
class TOutputImage,
class TStructuringElement>
69 StructuringElementType se;
70 se.SetRadius(m_Radius);
71 se.CreateStructuringElement();
74 m_OpeningFilter->SetInput(this->GetInput());
75 m_OpeningFilter->SetKernel(se);
76 m_OpeningFilter->SetPreserveIntensities(m_PreserveIntensities);
77 m_OpeningFilter->SetFullyConnected(m_FullyConnected);
79 m_ClosingFilter->SetInput(this->GetInput());
80 m_ClosingFilter->SetKernel(se);
81 m_ClosingFilter->SetPreserveIntensities(m_PreserveIntensities);
82 m_ClosingFilter->SetFullyConnected(m_FullyConnected);
84 m_ConvexFilter->SetInput1(this->GetInput());
85 m_ConvexFilter->SetInput2(m_OpeningFilter->GetOutput());
87 m_ConcaveFilter->SetInput1(m_ClosingFilter->GetOutput());
88 m_ConcaveFilter->SetInput2(this->GetInput());
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());
97 m_ConvexFilter->GraftOutput(this->GetConvexMap());
98 m_ConvexFilter->Update();
99 this->GraftNthOutput(1, m_ConvexFilter->GetOutput());
101 m_ConcaveFilter->GraftOutput(this->GetConcaveMap());
102 m_ConcaveFilter->Update();
103 this->GraftNthOutput(2, m_ConcaveFilter->GetOutput());
105 m_LevelingFilter->GraftOutput(this->GetOutput());
106 m_LevelingFilter->Update();
107 this->GraftOutput(m_LevelingFilter->GetOutput());
113 template <
class TInputImage,
class TOutputImage,
class TStructuringElement>
116 if (this->GetNumberOfOutputs() < 2)
120 return static_cast<OutputImageType*
>(this->itk::ProcessObject::GetOutput(1));
127 template <
class TInputImage,
class TOutputImage,
class TStructuringElement>
130 if (this->GetNumberOfOutputs() < 3)
134 return static_cast<OutputImageType*
>(this->itk::ProcessObject::GetOutput(2));