18#ifndef itkMultiphaseFiniteDifferenceImageFilter_h
19#define itkMultiphaseFiniteDifferenceImageFilter_h
23#include "vnl/vnl_vector.h"
157template <
typename TInputImage,
158 typename TFeatureImage,
159 typename TOutputImage,
160 typename TFiniteDifferenceFunction = FiniteDifferenceFunction<TOutputImage>,
161 typename TIdCell =
unsigned int>
177 static constexpr unsigned int ImageDimension = TOutputImage::ImageDimension;
218 using TimeStepType =
typename FiniteDifferenceFunctionType::TimeStepType;
220 using RadiusType =
typename FiniteDifferenceFunctionType::RadiusType;
236 if (functionIndex < m_FunctionCount)
238 return (this->m_DifferenceFunctions[functionIndex]);
254 if (functionIndex < m_FunctionCount)
256 this->m_DifferenceFunctions[functionIndex] = function;
262 itkSetMacro(NumberOfIterations,
unsigned int);
263 itkGetConstReferenceMacro(NumberOfIterations,
unsigned int);
268 itkSetMacro(UseImageSpacing,
bool);
269 itkBooleanMacro(UseImageSpacing);
270 itkGetConstReferenceMacro(UseImageSpacing,
bool);
275 itkSetMacro(MaximumRMSError,
double);
276 itkGetConstReferenceMacro(MaximumRMSError,
double);
281 itkSetMacro(RMSChange,
double);
282 itkGetConstReferenceMacro(RMSChange,
double);
286 itkSetMacro(InitializedState,
bool);
287 itkGetConstReferenceMacro(InitializedState,
bool);
288 itkBooleanMacro(InitializedState);
293 itkSetMacro(ManualReinitialization,
bool);
294 itkGetConstReferenceMacro(ManualReinitialization,
bool);
295 itkBooleanMacro(ManualReinitialization);
299 itkSetMacro(ElapsedIterations,
unsigned int);
302 itkGetConstReferenceMacro(ElapsedIterations,
unsigned int);
308 m_LevelSet[i]->SetRequestedRegion(levelSet->GetRequestedRegion());
309 m_LevelSet[i]->SetBufferedRegion(levelSet->GetBufferedRegion());
310 m_LevelSet[i]->SetLargestPossibleRegion(levelSet->GetLargestPossibleRegion());
311 m_LevelSet[i]->Allocate();
312 m_LevelSet[i]->CopyInformation(levelSet);
331 if (i >= m_FunctionCount)
333 itkExceptionMacro(
"Request for level set #" << i <<
" but there are only " << m_FunctionCount);
337 return m_LevelSet[i];
344 this->m_Lookup = lookup;
350 this->m_KdTree = kdtree;
358 m_DifferenceFunctions.resize(m_FunctionCount,
nullptr);
360 auto radius = MakeFilled<RadiusType>(1);
362 for (
unsigned int i = 0; i < this->m_FunctionCount; ++i)
365 this->m_DifferenceFunctions[i]->Initialize(radius);
369 m_LevelSet.resize(m_FunctionCount,
nullptr);
372 this->m_Lookup.resize(m_FunctionCount);
377 auto it = this->m_Lookup.begin();
378 auto _end = this->m_Lookup.end();
391 this->m_KdTree =
nullptr;
392 this->m_ElapsedIterations = 0;
395 this->m_UseImageSpacing =
true;
396 this->m_ManualReinitialization =
false;
397 this->m_InitializedState =
false;
399 this->m_FunctionCount = 0;
406 std::vector<InputImagePointer> m_LevelSet{};
410 unsigned int m_ElapsedIterations{};
411 double m_MaximumRMSError{};
412 double m_RMSChange{};
413 unsigned int m_NumberOfIterations{};
416 std::vector<FiniteDifferenceFunctionPointer> m_DifferenceFunctions{};
420 bool m_UseImageSpacing{};
507 for (
IdCellType i = 0; i < this->m_FunctionCount; ++i)
509 this->m_DifferenceFunctions[i]->InitializeIteration();
539 bool m_ManualReinitialization{};
542 bool m_InitializedState{};
546#ifndef ITK_MANUAL_INSTANTIATION
547# include "itkMultiphaseFiniteDifferenceImageFilter.hxx"
A multi-dimensional iterator templated over image type that walks a region of pixels.
A multi-dimensional iterator templated over image type that walks a region of pixels.
void Set(const PixelType &value) const
Base class for all process objects that output image data.
TOutputImage OutputImageType
typename OutputImageType::Pointer OutputImagePointer
Base class for filters that take an image as input and overwrite that image as the output.
Control indentation during Print() invocation.
typename FeatureImageType::SpacingType FeatureSpacingType
typename InputImageType::IndexType InputIndexType
virtual void AllocateUpdateBuffer()=0
std::vector< IdCellType > VectorIdCellType
typename InputIndexType::IndexValueType InputIndexValueType
typename InputPointType::CoordRepType InputCoordRepType
typename InputImageType::SpacingType InputSpacingType
virtual void ApplyUpdate(TimeStepType dt)=0
typename InputImageType::SizeType InputSizeType
typename OutputImageType::RegionType OutputRegionType
virtual void SetDifferenceFunction(const IdCellType &functionIndex, FiniteDifferenceFunctionPointer function)
void SetLevelSet(const IdCellType &i, const InputImageType *levelSet)
TFeatureImage FeatureImageType
typename OutputImageType::IndexValueType OutputIndexValueType
virtual void PostProcessOutput()
virtual void CopyInputToOutput()=0
void GenerateInputRequestedRegion() override
typename OutputImageType::IndexType OutputIndexType
typename FiniteDifferenceFunctionType::Pointer FiniteDifferenceFunctionPointer
virtual void InitializeIteration()
typename FiniteDifferenceFunctionType::TimeStepType TimeStepType
typename InputImageType::PointType InputPointType
void SetLookup(VectorIdCellType lookup)
~MultiphaseFiniteDifferenceImageFilter() override=default
void SetFunctionCount(const IdCellType &n)
typename FeatureImageType::SizeType FeatureSizeType
typename KdTreeType::Pointer KdTreePointer
virtual void Initialize()
typename OutputImageType::PixelType OutputPixelType
typename OutputImageType::SizeType OutputSizeType
virtual const FiniteDifferenceFunctionPointer GetDifferenceFunction(const IdCellType &functionIndex) const
TInputImage InputImageType
typename KdTreeGeneratorType::KdTreeType KdTreeType
InputImagePointer GetLevelSet(const IdCellType &i)
typename FiniteDifferenceFunctionType::RadiusType RadiusType
typename FeatureImageType::RegionType FeatureRegionType
typename InputImageType::OffsetValueType InputOffsetValueType
typename FeatureImageType::PointType FeaturePointType
TimeStepType ResolveTimeStep(const TimeStepVectorType &timeStepList, const std::vector< uint8_t > &valid)
typename KdTreeGeneratorType::Pointer KdTreeGeneratorPointer
typename InputImageType::PixelType InputPixelType
typename InputSizeType::SizeValueType InputSizeValueType
typename InputImageType::RegionType InputRegionType
void GenerateData() override
typename FeatureImageType::Pointer FeatureImagePointer
void PrintSelf(std::ostream &os, Indent indent) const override
typename std::vector< TimeStepType > TimeStepVectorType
typename InputImageType::Pointer InputImagePointer
typename FeatureImageType::PixelType FeaturePixelType
MultiphaseFiniteDifferenceImageFilter()
virtual bool ThreadedHalt(void *)
virtual TimeStepType CalculateChange()=0
typename OutputImageType::SizeValueType OutputSizeValueType
void SetKdTree(KdTreeType *kdtree)
TFiniteDifferenceFunction FiniteDifferenceFunctionType
static constexpr T max(const T &)
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
This class generates a KdTree object without centroid information.
This class provides methods for k-nearest neighbor search and related data structures for a k-d tree.
This class is the native implementation of the a Sample with an STL container.
A templated class holding a n-Dimensional vector.
SmartPointer< Self > Pointer
ImageBaseType::RegionType RegionType
ImageBaseType::IndexType IndexType
ImageBaseType::PointType PointType
ImageBaseType::SizeType SizeType
static constexpr double eps
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
unsigned long SizeValueType