21 #ifndef otbClosingOpeningMorphologicalFilter_hxx
22 #define otbClosingOpeningMorphologicalFilter_hxx
25 #include "itkGrayscaleMorphologicalOpeningImageFilter.h"
26 #include "itkGrayscaleMorphologicalClosingImageFilter.h"
27 #include "itkProgressAccumulator.h"
34 template <
class TInputImage,
class TOutputImage,
class TKernel>
37 m_Kernel.SetRadius(1);
38 m_Kernel.CreateStructuringElement();
44 template <
class TInputImage,
class TOutputImage,
class TKernel>
48 typedef itk::GrayscaleMorphologicalOpeningImageFilter<InputImageType, OutputImageType, KernelType> OpenFilterType;
49 typedef itk::GrayscaleMorphologicalClosingImageFilter<InputImageType, OutputImageType, KernelType> CloseFilterType;
51 typename OpenFilterType::Pointer opening = OpenFilterType::New();
52 typename CloseFilterType::Pointer closing = CloseFilterType::New();
54 opening->SetKernel(this->GetKernel());
55 closing->SetKernel(this->GetKernel());
57 itk::ProgressAccumulator::Pointer progress = itk::ProgressAccumulator::New();
58 progress->SetMiniPipelineFilter(
this);
59 progress->RegisterInternalFilter(closing, .5f);
60 progress->RegisterInternalFilter(opening, .5f);
62 opening->SetInput(this->GetInput());
63 closing->SetInput(opening->GetOutput());
65 closing->GraftOutput(this->GetOutput());
67 this->GraftOutput(closing->GetOutput());