21 #ifndef otbLabelMapWithClassLabelToLabeledSampleListFilter_hxx
22 #define otbLabelMapWithClassLabelToLabeledSampleListFilter_hxx
25 #include "itkDataObject.h"
30 template <
class TInputLabelMap,
class TOutputListSample,
class TOutputTrainingListSample,
class TMeasurementFunctor>
31 LabelMapWithClassLabelToLabeledSampleListFilter<TInputLabelMap, TOutputListSample, TOutputTrainingListSample,
34 this->SetNumberOfRequiredOutputs(2);
35 this->itk::ProcessObject::SetNthOutput(1, this->MakeOutput(1).GetPointer());
38 template <
class TInputLabelMap,
class TOutputListSample,
class TOutputTrainingListSample,
class TMeasurementFunctor>
40 TMeasurementFunctor>::~LabelMapWithClassLabelToLabeledSampleListFilter()
45 template <
class TInputLabelMap,
class TOutputListSample,
class TOutputTrainingListSample,
class TMeasurementFunctor>
47 TMeasurementFunctor>::DataObjectPointerType
56 output =
static_cast<itk::DataObject*
>(OutputSampleListType::New().GetPointer());
59 output =
static_cast<itk::DataObject*
>(OutputTrainingSampleListType::New().GetPointer());
62 output =
static_cast<itk::DataObject*
>(OutputSampleListType::New().GetPointer());
70 template <
class TInputLabelMap,
class TOutputListSample,
class TOutputTrainingListSample,
class TMeasurementFunctor>
72 TMeasurementFunctor>::OutputTrainingSampleListType*
74 TMeasurementFunctor>::GetOutputTrainingSampleList()
79 template <
class TInputLabelMap,
class TOutputListSample,
class TOutputTrainingListSample,
class TMeasurementFunctor>
91 outputSampleList->Clear();
92 outputTrainingSampleList->Clear();
97 bool isFirstIteration =
true;
102 if (it.GetLabelObject()->HasClassLabel())
104 label[0] =
static_cast<typename TraningVectorType::ValueType
>(it.GetLabelObject()->GetClassLabel());
108 label[0] = itk::NumericTraits<typename InputLabelMapType::LabelObjectType::ClassLabelType>::max();
112 if (isFirstIteration)
115 typename OutputSampleListType::MeasurementVectorSizeType measurementSize;
116 measurementSize = m_MeasurementFunctor(it.GetLabelObject()).Size();
117 outputSampleList->SetMeasurementVectorSize(measurementSize);
120 outputTrainingSampleList->SetMeasurementVectorSize(label.Size());
121 isFirstIteration =
false;
124 outputSampleList->PushBack(m_MeasurementFunctor(it.GetLabelObject()));
125 outputTrainingSampleList->PushBack(label);
130 template <
class TInputLabelMap,
class TOutputListSample,
class TOutputTrainingListSample,
class TMeasurementFunctor>
132 std::ostream& os, itk::Indent indent)
const
134 Superclass::PrintSelf(os, indent);