21 #ifndef otbImageToLabelMapWithAttributesFilter_hxx
22 #define otbImageToLabelMapWithAttributesFilter_hxx
25 #include "itkProcessObject.h"
29 template <
class TInputImage,
class TLabeledImage,
class TOutputLabel,
class TObjectLabel>
32 m_Output = LabelMapType::New();
33 this->itk::ProcessObject::SetNumberOfRequiredInputs(2);
36 template <
class TInputImage,
class TLabeledImage,
class TOutputLabel,
class TObjectLabel>
40 Superclass::GenerateInputRequestedRegion();
43 typename InputImageType::Pointer input =
const_cast<InputImageType*
>(this->GetInput());
50 input->SetRequestedRegion(input->GetLargestPossibleRegion());
53 template <
class TInputImage,
class TLabeledImage,
class TOutputLabel,
class TObjectLabel>
57 this->itk::ProcessObject::SetNthInput(0,
const_cast<InputImageType*
>(image));
60 template <
class TInputImage,
class TLabeledImage,
class TOutputLabel,
class TObjectLabel>
64 this->itk::ProcessObject::SetNthInput(1,
const_cast<LabeledImageType*
>(image));
67 template <
class TInputImage,
class TLabeledImage,
class TOutputLabel,
class TObjectLabel>
71 if (this->GetNumberOfInputs() < 2)
76 return static_cast<const InputImageType*
>(this->itk::ProcessObject::GetInput(0));
79 template <
class TInputImage,
class TLabeledImage,
class TOutputLabel,
class TObjectLabel>
83 if (this->GetNumberOfInputs() < 2)
88 return static_cast<const LabeledImageType*
>(this->itk::ProcessObject::GetInput(1));
92 template <
class TInputImage,
class TLabeledImage,
class TOutputLabel,
class TObjectLabel>
96 return dynamic_cast<LabelMapType*
>(this->Superclass::GetOutput(0));
100 template <
class TInputImage,
class TLabeledImage,
class TOutputLabel,
class TObjectLabel>
103 typename InputImageType::Pointer inputImage =
const_cast<InputImageType*
>(this->GetInput());
104 typename LabeledImageType::Pointer labeldImage =
const_cast<LabeledImageType*
>(this->GetLabeledImage());
108 lfilter->SetBackgroundValue(itk::NumericTraits<LabelType>::max());
109 lfilter->SetInput(labeldImage);
113 shapeLabelMapFilter->SetInput(lfilter->GetOutput());
117 bandStatsLabelMapFilter->SetInput(shapeLabelMapFilter->GetOutput());
118 bandStatsLabelMapFilter->SetFeatureImage(inputImage);
121 bandStatsLabelMapFilter->GetOutput()->SetAdjacencyMap(lfilter->GetOutput()->GetAdjacencyMap());
122 bandStatsLabelMapFilter->GraftOutput(this->GetOutput());
125 bandStatsLabelMapFilter->Update();
128 this->GraftOutput(bandStatsLabelMapFilter->GetOutput());