21 #ifndef otbMeanShiftSegmentationFilter_hxx
22 #define otbMeanShiftSegmentationFilter_hxx
29 template <
class TInputImage,
class TOutputLabelImage,
class TOutputClusteredImage,
class TKernel>
32 m_MeanShiftFilter = MeanShiftFilterType::New();
33 m_RegionMergingFilter = RegionMergingFilterType::New();
34 m_RegionPruningFilter = RegionPruningFilterType::New();
35 m_RelabelFilter = RelabelComponentFilterType::New();
36 this->SetMinRegionSize(100);
37 this->SetNumberOfRequiredOutputs(2);
38 this->SetNthOutput(0, TOutputLabelImage::New());
39 this->SetNthOutput(1, TOutputClusteredImage::New());
41 m_MeanShiftFilter->SetModeSearch(
true);
44 template <
class TInputImage,
class TOutputLabelImage,
class TOutputClusteredImage,
class TKernel>
49 template <
class TInputImage,
class TOutputLabelImage,
class TOutputClusteredImage,
class TKernel>
55 template <
class TInputImage,
class TOutputLabelImage,
class TOutputClusteredImage,
class TKernel>
58 return static_cast<OutputLabelImageType*
>(this->itk::ProcessObject::GetOutput(0));
61 template <
class TInputImage,
class TOutputLabelImage,
class TOutputClusteredImage,
class TKernel>
68 template <
class TInputImage,
class TOutputLabelImage,
class TOutputClusteredImage,
class TKernel>
72 return static_cast<OutputClusteredImageType*
>(this->itk::ProcessObject::GetOutput(1));
75 template <
class TInputImage,
class TOutputLabelImage,
class TOutputClusteredImage,
class TKernel>
78 this->m_MeanShiftFilter->SetInput(this->GetInput());
82 m_RelabelFilter->SetInput(this->m_MeanShiftFilter->GetLabelOutput());
83 this->m_RegionMergingFilter->SetInputLabelImage(this->m_RelabelFilter->GetOutput());
85 this->m_RegionMergingFilter->SetInputSpectralImage(this->m_MeanShiftFilter->GetRangeOutput());
86 this->m_RegionMergingFilter->SetRangeBandwidth(this->GetRangeBandwidth());
87 if (this->GetMinRegionSize() == 0)
90 m_RegionMergingFilter->GraftNthOutput(0, this->GetLabelOutput());
91 m_RegionMergingFilter->GraftNthOutput(1, this->GetClusteredOutput());
92 this->m_RegionMergingFilter->Update();
93 this->GraftNthOutput(0, m_RegionMergingFilter->GetLabelOutput());
94 this->GraftNthOutput(1, m_RegionMergingFilter->GetClusteredOutput());
99 this->m_RegionPruningFilter->SetInputLabelImage(this->m_RegionMergingFilter->GetLabelOutput());
100 this->m_RegionPruningFilter->SetInputSpectralImage(this->m_RegionMergingFilter->GetClusteredOutput());
101 m_RegionPruningFilter->GraftNthOutput(0, this->GetLabelOutput());
102 m_RegionPruningFilter->GraftNthOutput(1, this->GetClusteredOutput());
104 this->m_RegionPruningFilter->Update();
105 this->GraftNthOutput(0, m_RegionPruningFilter->GetLabelOutput());
106 this->GraftNthOutput(1, m_RegionPruningFilter->GetClusteredOutput());