diff --git a/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.h b/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.h index dbe4a044d..78a71c9b7 100644 --- a/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.h +++ b/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.h @@ -93,7 +93,7 @@ class HistogramParzenWindowsListSampleFunction final : public ListSampleFunction unsigned int m_NumberOfHistogramBins; RealType m_Sigma; - InterpolatorPointer m_Interpolator; + std::vector m_Interpolators; std::vector m_HistogramImages; }; } // end of namespace Statistics diff --git a/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.hxx b/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.hxx index cc73b7cfb..e48578aa2 100644 --- a/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.hxx +++ b/ImageSegmentation/antsHistogramParzenWindowsListSampleFunction.hxx @@ -32,9 +32,6 @@ namespace Statistics template HistogramParzenWindowsListSampleFunction::HistogramParzenWindowsListSampleFunction() { - this->m_Interpolator = InterpolatorType::New(); - this->m_Interpolator->SetSplineOrder(3); - this->m_NumberOfHistogramBins = 32; this->m_Sigma = 1.0; } @@ -187,6 +184,15 @@ HistogramParzenWindowsListSampleFunction::SetIn divider->Update(); this->m_HistogramImages[d] = divider->GetOutput(); } + + this->m_Interpolators.clear(); + this->m_Interpolators.resize(this->m_HistogramImages.size()); + for (size_t d = 0; d < m_HistogramImages.size(); ++d) + { + this->m_Interpolators[d] = InterpolatorType::New(); + this->m_Interpolators[d]->SetSplineOrder(3); + this->m_Interpolators[d]->SetInputImage(m_HistogramImages[d]); + } } template @@ -202,10 +208,9 @@ HistogramParzenWindowsListSampleFunction::Evalu typename HistogramImageType::PointType point; point[0] = measurement[d]; - this->m_Interpolator->SetInputImage(this->m_HistogramImages[d]); - if (this->m_Interpolator->IsInsideBuffer(point)) + if (this->m_Interpolators[d]->IsInsideBuffer(point)) { - probability *= static_cast(this->m_Interpolator->Evaluate(point)); + probability *= static_cast(this->m_Interpolators[d]->Evaluate(point)); } else {