22 #ifndef otbPathListToHistogramGenerator_hxx
23 #define otbPathListToHistogramGenerator_hxx
30 template <
class TPath,
class TFunction>
33 m_HistogramGenerator = GeneratorType::New();
35 this->SetNumberOfRequiredInputs(1);
36 this->SetNumberOfRequiredOutputs(1);
38 this->itk::ProcessObject::SetNthOutput(0, this->MakeOutput(0).GetPointer());
41 template <
class TPath,
class TFunction>
45 this->itk::ProcessObject::SetNthInput(0,
const_cast<PathListType*
>(path));
48 template <
class TPath,
class TFunction>
51 if (this->GetNumberOfInputs() < 1)
55 return static_cast<const PathListType*
>(this->itk::ProcessObject::GetInput(0));
61 template <
class TPath,
class TFunction>
64 this->GraftNthOutput(0, graft);
71 template <
class TPath,
class TFunction>
74 if (idx >= this->GetNumberOfOutputs())
76 itkExceptionMacro(<<
"Requested to graft output " << idx <<
" but this filter only has " << this->GetNumberOfOutputs() <<
" Outputs.");
81 itkExceptionMacro(<<
"Requested to graft output that is a NULL pointer");
84 itk::DataObject* output =
const_cast<HistogramType*
>(this->GetOutput());
90 template <
class TPath,
class TFunction>
95 output =
static_cast<itk::DataObject*
>(HistogramType::New().GetPointer());
100 template <
class TPath,
class TFunction>
103 return dynamic_cast<const HistogramType*
>(this->itk::ProcessObject::GetOutput(0));
106 template <
class TPath,
class TFunction>
116 int nbElementPathList = pathList->Size();
120 typename TFunction::Pointer
function = TFunction::New();
122 for (
int noPathList = 0; noPathList < nbElementPathList; noPathList++)
124 vertexList = pathList->GetNthElement(noPathList);
125 function->SetInputPath(vertexList);
127 ResultFunction[0] =
static_cast<MeasurementType>(
function->Evaluate());
130 listSample->SetMeasurementVectorSize(ResultFunction.Size());
132 listSample->PushBack(ResultFunction);
135 m_HistogramGenerator->SetInput(listSample);
136 m_HistogramGenerator->GraftOutput(
const_cast<HistogramType*
>(this->GetOutput()));
137 m_HistogramGenerator->Update();
138 this->GraftOutput(
const_cast<HistogramType*
>(m_HistogramGenerator->GetOutput()));
141 template <
class TPath,
class TFunction>
144 m_HistogramGenerator->SetHistogramSize(size);
147 template <
class TPath,
class TFunction>
150 m_HistogramGenerator->SetMarginalScale(marginalScale);
153 template <
class TPath,
class TFunction>
156 m_HistogramGenerator->SetHistogramMin(histogramMin);
159 template <
class TPath,
class TFunction>
162 m_HistogramGenerator->SetHistogramMax(histogramMax);
165 template <
class TPath,
class TFunction>
168 m_HistogramGenerator->SetAutoMinMax(autoMinMax);
171 template <
class TPath,
class TFunction>
174 Superclass::PrintSelf(os, indent);
175 os <<
"PathList = " << this->GetInput() << std::endl;
176 os <<
"HistogramGenerator = " << m_HistogramGenerator << std::endl;