21 #ifndef otbGeodesicMorphologyIterativeDecompositionImageFilter_hxx
22 #define otbGeodesicMorphologyIterativeDecompositionImageFilter_hxx
26 #include "itkProgressAccumulator.h"
34 template <
class TImage,
class TStructuringElement>
38 m_Progress = itk::ProgressAccumulator::New();
39 m_Progress->SetMiniPipelineFilter(
this);
42 this->SetNumberOfRequiredInputs(1);
43 this->SetNumberOfRequiredOutputs(3);
44 m_NumberOfIterations = 2;
47 OutputImageListPointerType convList = OutputImageListType::New();
48 this->SetNthOutput(0, convList.GetPointer());
49 OutputImageListPointerType concList = OutputImageListType::New();
50 this->SetNthOutput(1, concList.GetPointer());
51 OutputImageListPointerType outputList = OutputImageListType::New();
52 this->SetNthOutput(2, outputList.GetPointer());
55 template <
class TImage,
class TStructuringElement>
59 return dynamic_cast<OutputImageListType*
>(this->itk::ProcessObject::GetOutput(2));
62 template <
class TImage,
class TStructuringElement>
66 return dynamic_cast<OutputImageListType*
>(this->itk::ProcessObject::GetOutput(0));
69 template <
class TImage,
class TStructuringElement>
73 return dynamic_cast<OutputImageListType*
>(this->itk::ProcessObject::GetOutput(1));
76 template <
class TImage,
class TStructuringElement>
80 InputImagePointerType inputPtr = this->GetInput();
81 OutputImageListPointerType outputPtr = this->GetOutput();
82 OutputImageListPointerType convOutputPtr = this->GetConvexOutput();
83 OutputImageListPointerType concOutputPtr = this->GetConcaveOutput();
86 if (outputPtr->Size() != m_NumberOfIterations)
90 for (
unsigned int i = 0; i < m_NumberOfIterations; ++i)
93 outputPtr->PushBack(OutputImageType::New());
97 typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
98 while (outputListIt != outputPtr->End())
101 outputListIt.Get()->CopyInformation(this->GetInput());
102 outputListIt.Get()->SetRequestedRegion(this->GetInput()->GetLargestPossibleRegion());
108 if (convOutputPtr->Size() != m_NumberOfIterations)
111 convOutputPtr->Clear();
112 for (
unsigned int i = 0; i < m_NumberOfIterations; ++i)
115 convOutputPtr->PushBack(OutputImageType::New());
119 typename OutputImageListType::Iterator outputListIt = convOutputPtr->Begin();
120 while (outputListIt != convOutputPtr->End())
123 outputListIt.Get()->CopyInformation(this->GetInput());
124 outputListIt.Get()->SetRequestedRegion(this->GetInput()->GetLargestPossibleRegion());
130 if (concOutputPtr->Size() != m_NumberOfIterations)
133 concOutputPtr->Clear();
134 for (
unsigned int i = 0; i < m_NumberOfIterations; ++i)
137 concOutputPtr->PushBack(OutputImageType::New());
141 typename OutputImageListType::Iterator outputListIt = concOutputPtr->Begin();
142 while (outputListIt != concOutputPtr->End())
145 outputListIt.Get()->CopyInformation(this->GetInput());
146 outputListIt.Get()->SetRequestedRegion(this->GetInput()->GetLargestPossibleRegion());
152 template <
class TImage,
class TStructuringElement>
156 InputImagePointerType inputPtr = this->GetInput();
157 OutputImageListPointerType outputPtr = this->GetOutput();
160 typename OutputImageListType::Iterator outputListIt = outputPtr->Begin();
161 inputPtr->SetRequestedRegion(outputListIt.Get()->GetRequestedRegion());
167 template <
class TImage,
class TStructuringElement>
171 InputImagePointerType current = this->GetInput();
172 OutputImageListPointerType outputPtr = this->GetOutput();
173 OutputImageListPointerType convOutputPtr = this->GetConvexOutput();
174 OutputImageListPointerType concOutputPtr = this->GetConcaveOutput();
179 DecompositionFilterPointerType filter;
181 while (i < m_NumberOfIterations)
183 filter = DecompositionFilterType::New();
186 m_Progress->RegisterInternalFilter(filter, 1. / m_NumberOfIterations);
188 typename StructuringElementType::RadiusType radius;
189 radius.Fill(m_InitialValue + i * m_Step);
190 filter->SetRadius(radius);
191 filter->SetInput(current);
192 filter->GetOutput()->UpdateOutputInformation();
193 filter->GetOutput()->SetRequestedRegion(outputPtr->GetNthElement(i)->GetRequestedRegion());
194 filter->GetOutput()->PropagateRequestedRegion();
195 filter->GetOutput()->UpdateOutputData();
197 outputPtr->SetNthElement(i, filter->GetOutput());
198 concOutputPtr->SetNthElement(i, filter->GetConcaveMap());
199 convOutputPtr->SetNthElement(i, filter->GetConvexMap());
201 current = filter->GetOutput();