21 #ifndef otbLabelizeImageFilterBase_hxx
22 #define otbLabelizeImageFilterBase_hxx
31 template <
class TInputImage,
class TOutputImage,
class TFilter>
34 m_LowerThreshold = itk::NumericTraits<InputPixelType>::NonpositiveMin();
35 m_UpperThreshold = itk::NumericTraits<InputPixelType>::max();
38 m_MultiplyFilter = MultiplyFilterType::New();
39 m_MultiplyFilter->SetCoef(0.0);
41 m_ThresholdPointSetFilter = ThresholdFilterType::New();
43 m_RegionGrowingFilter = RegionGrowingFilterType::New();
49 template <
class TInputImage,
class TOutputImage,
class TFilter>
53 m_RegionGrowingFilter->SetInput(this->GetInput());
56 m_MultiplyFilter->SetInput(this->GetInput());
57 m_MultiplyFilter->Update();
60 m_ThresholdPointSetFilter->SetInput(0, this->GetInput());
61 m_ThresholdPointSetFilter->SetLowerThreshold(m_LowerThreshold);
62 m_ThresholdPointSetFilter->SetUpperThreshold(m_UpperThreshold);
63 m_ThresholdPointSetFilter->Update();
64 m_PointSet = m_ThresholdPointSetFilter->GetOutput();
68 typedef typename PointSetType::PointsContainer ContainerType;
69 ContainerType* pointsContainer = m_PointSet->GetPoints();
70 typedef typename ContainerType::Iterator IteratorType;
71 IteratorType itList = pointsContainer->Begin();
73 typename OutputImageType::Pointer outputImage = m_MultiplyFilter->GetOutput();
75 while (itList != pointsContainer->End())
77 typename PointSetType::PointType pCoordinate = (itList.Value());
78 typename InputImageType::IndexType index;
80 index[0] =
static_cast<int>(pCoordinate[0]);
81 index[1] =
static_cast<int>(pCoordinate[1]);
82 if (outputImage->GetPixel(index) == itk::NumericTraits<OutputPixelType>::ZeroValue())
84 this->RegionGrowing(index);
87 addImage->SetInput1(outputImage);
88 addImage->SetInput2(m_RegionGrowingFilter->GetOutput());
90 outputImage = addImage->GetOutput();
96 this->GraftOutput(outputImage);
102 template <
class TInputImage,
class TOutputImage,
class TFilter>
105 Superclass::PrintSelf(os, indent);
107 os << indent <<
"Seeds lower threshold: " << m_LowerThreshold << std::endl;
108 os << indent <<
"Seeds upper threshold: " << m_UpperThreshold << std::endl;
109 os << indent <<
"ObjectCount: " << m_ObjectCount << std::endl;
110 os << indent << m_RegionGrowingFilter << std::endl;