21 #ifndef otbMeanShiftConnectedComponentSegmentationFilter_hxx
22 #define otbMeanShiftConnectedComponentSegmentationFilter_hxx
25 #include "itkExtractImageFilter.h"
30 template <
class TVImage,
class TMaskImage,
class TLabelImage>
33 m_MinimumObjectSize = 2;
34 m_MeanShiftFilter = MeanShiftFilterType::New();
37 template <
class TVImage,
class TMaskImage,
class TLabelImage>
42 template <
class TVImage,
class TMaskImage,
class TLabelImage>
45 Superclass::GenerateInputRequestedRegion();
48 template <
class TVImage,
class TMaskImage,
class TLabelImage>
52 typedef itk::ExtractImageFilter<TVImage, TVImage> ExtractImageFilterType;
53 typename ExtractImageFilterType::Pointer extract = ExtractImageFilterType::New();
54 extract->SetInput(this->GetInput());
55 extract->SetExtractionRegion(this->GetOutput()->GetRequestedRegion());
65 this->m_MeanShiftFilter->SetInput(extract->GetOutput());
70 typename MaskImageType::Pointer mask;
71 if (!m_MaskExpression.empty())
75 maskFilter = MaskMuParserFilterType::New();
76 maskFilter->SetInput(this->m_MeanShiftFilter->GetOutput());
77 maskFilter->SetExpression(m_MaskExpression);
79 mask = maskFilter->GetOutput();
83 typename ConnectedComponentFilterType::Pointer connected = ConnectedComponentFilterType::New();
84 connected->SetInput(this->m_MeanShiftFilter->GetOutput());
87 connected->SetMaskImage(mask);
88 connected->GetFunctor().SetExpression(m_ConnectedComponentExpression);
92 typename RelabelComponentFilterType::Pointer relabel = RelabelComponentFilterType::New();
93 relabel->SetInput(connected->GetOutput());
94 relabel->SetMinimumObjectSize(m_MinimumObjectSize);
97 this->GraftOutput(relabel->GetOutput());