ITK  5.0.0
Insight Segmentation and Registration Toolkit
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
itk::FiniteDifferenceFunction< TImageType > Class Template Referenceabstract

#include <itkFiniteDifferenceFunction.h>

+ Inheritance diagram for itk::FiniteDifferenceFunction< TImageType >:
+ Collaboration diagram for itk::FiniteDifferenceFunction< TImageType >:

Detailed Description

template<typename TImageType>
class itk::FiniteDifferenceFunction< TImageType >

This class is a component object of the finite difference solver hierarchy (see FiniteDifferenceImageFilter). It defines a generic interface for a function object that computes a single scalar value from a neighborhood of values. Examples of the application of this class are the various flavors of AnisotropicDiffusionFunction and LevelSetFunction objects.

These functions calculate the incremental change at a pixel in the solution image from one iteration of the Partial Differential Equation (PDE) solver to the next.

Subclasses of FiniteDifferenceImageFilter (solvers) call the ComputeUpdate() method of this class to compute $ \Delta u^n_{\mathbf{i}} $ at each $ \mathbf{i} $ in $ u $. Because the size of the time step for each iteration of the p.d.e. solution depends on the particular calculations done, this function object is also responsible for computing that time step (see ComputeGlobalTimeStep() ).
How to use this class
FiniteDifferenceFunction must be subclassed to add functionality for ComputeUpdate, ComputeGlobalTimeStep, and Get/ReleaseGlobalDataPointer.
A note on thread safety.
The ComputeUpdate() methods of this filter are declared as const to enforce thread-safety during execution of FiniteDifferenceImageFilter solver algorithms. The InitializeIteration() method is intended to provide a safe way to modify the state of the object between threaded calculations of solvers.
Todo:
Possibly subclass this object from Function. Stumbling blocks here are the specialized api of FiniteDifferenceFunction.

Definition at line 66 of file itkFiniteDifferenceFunction.h.

Public Types

using ConstPointer = SmartPointer< const Self >
 
using DefaultBoundaryConditionType = ZeroFluxNeumannBoundaryCondition< ImageType >
 
using FloatOffsetType = Vector< float, Self::ImageDimension >
 
using ImageType = TImageType
 
using NeighborhoodScalesType = Vector< PixelRealType, Self::ImageDimension >
 
using NeighborhoodType = ConstNeighborhoodIterator< TImageType, DefaultBoundaryConditionType >
 
using PixelRealType = double
 
using PixelType = typename ImageType::PixelType
 
using Pointer = SmartPointer< Self >
 
using RadiusType = typename ConstNeighborhoodIterator< TImageType >::RadiusType
 
using Self = FiniteDifferenceFunction
 
using Superclass = LightObject
 
using TimeStepType = double
 
- Public Types inherited from itk::LightObject
using ConstPointer = SmartPointer< const Self >
 
using Pointer = SmartPointer< Self >
 
using Self = LightObject
 

Public Member Functions

virtual TimeStepType ComputeGlobalTimeStep (void *GlobalData) const =0
 
const NeighborhoodScalesType ComputeNeighborhoodScales () const
 
virtual PixelType ComputeUpdate (const NeighborhoodType &neighborhood, void *globalData, const FloatOffsetType &offset=FloatOffsetType(0.0))=0
 
virtual void * GetGlobalDataPointer () const =0
 
virtual const char * GetNameOfClass () const
 
const RadiusTypeGetRadius () const
 
void GetScaleCoefficients (PixelRealType vals[ImageDimension]) const
 
virtual void InitializeIteration ()
 
virtual void ReleaseGlobalDataPointer (void *GlobalData) const =0
 
void SetRadius (const RadiusType &r)
 
void SetScaleCoefficients (PixelRealType vals[ImageDimension])
 
- Public Member Functions inherited from itk::LightObject
virtual Pointer CreateAnother () const
 
virtual void Delete ()
 
virtual int GetReferenceCount () const
 
 itkCloneMacro (Self)
 
void Print (std::ostream &os, Indent indent=0) const
 
virtual void Register () const
 
virtual void SetReferenceCount (int)
 
virtual void UnRegister () const noexcept
 

Static Public Attributes

static constexpr unsigned int ImageDimension = ImageType::ImageDimension
 

Protected Member Functions

 FiniteDifferenceFunction ()
 
void PrintSelf (std::ostream &os, Indent indent) const override
 
 ~FiniteDifferenceFunction () override=default
 
- Protected Member Functions inherited from itk::LightObject
virtual LightObject::Pointer InternalClone () const
 
 LightObject ()
 
virtual void PrintHeader (std::ostream &os, Indent indent) const
 
virtual void PrintTrailer (std::ostream &os, Indent indent) const
 
virtual ~LightObject ()
 

Protected Attributes

RadiusType m_Radius
 
PixelRealType m_ScaleCoefficients [ImageDimension]
 
- Protected Attributes inherited from itk::LightObject
std::atomic< int > m_ReferenceCount
 

Additional Inherited Members

- Static Public Member Functions inherited from itk::LightObject
static void BreakOnError ()
 
static Pointer New ()
 

Member Typedef Documentation

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::ConstPointer = SmartPointer< const Self >

Definition at line 76 of file itkFiniteDifferenceFunction.h.

The default boundary condition for finite difference functions that is used unless overridden in the Evaluate() method.

Definition at line 94 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::FloatOffsetType = Vector< float, Self::ImageDimension >

A floating point offset from an image grid location. Used for interpolation among grid values in a neighborhood.

Definition at line 109 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::ImageType = TImageType

Extract some parameters from the image type

Definition at line 82 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::NeighborhoodScalesType = Vector< PixelRealType, Self::ImageDimension >

The type of data structure that holds the scales with which the neighborhood is weighted to properly account for spacing and neighborhood radius.

Definition at line 105 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::NeighborhoodType = ConstNeighborhoodIterator< TImageType, DefaultBoundaryConditionType >

The type of data structure that is passed to this function object to evaluate at a pixel that does not lie on a data set boundary.

Definition at line 101 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::PixelRealType = double

Definition at line 84 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::PixelType = typename ImageType::PixelType

Definition at line 83 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::Pointer = SmartPointer< Self >

Definition at line 75 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::RadiusType = typename ConstNeighborhoodIterator< TImageType >::RadiusType

Neighborhood radius type

Definition at line 97 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::Self = FiniteDifferenceFunction

Standard class type aliases.

Definition at line 73 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::Superclass = LightObject

Definition at line 74 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
using itk::FiniteDifferenceFunction< TImageType >::TimeStepType = double

Define the TimeStepType to always be double.

Definition at line 90 of file itkFiniteDifferenceFunction.h.

Constructor & Destructor Documentation

template<typename TImageType>
itk::FiniteDifferenceFunction< TImageType >::FiniteDifferenceFunction ( )
protected
template<typename TImageType>
itk::FiniteDifferenceFunction< TImageType >::~FiniteDifferenceFunction ( )
overrideprotecteddefault

Member Function Documentation

template<typename TImageType>
virtual TimeStepType itk::FiniteDifferenceFunction< TImageType >::ComputeGlobalTimeStep ( void *  GlobalData) const
pure virtual

Computes the time step for an update given a global data structure. The data used in the computation may take different forms depending on the nature of the equations. This global data cannot be kept in the instance of the equation object itself since the equation object must remain stateless for thread safety. The global data is therefore managed for each thread by the finite difference solver filters.

Implemented in itk::AnisotropicDiffusionFunction< TImage >, itk::LevelSetFunction< TImageType >, itk::RegionBasedLevelSetFunction< TInput, TFeature, TSharedData >, itk::RegionBasedLevelSetFunction< TInputImage, TFeatureImage, TSharedData >, itk::VariationalRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::ESMDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationSSDFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::GPUDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationNCCFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::LevelSetMotionRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::SymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::DemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::FastSymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::MeanSquareRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::LevelSetFunctionWithRefitTerm< TImageType, TSparseImageType >, itk::ShapePriorSegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::GPUAnisotropicDiffusionFunction< TImage >, itk::NormalVectorFunctionBase< TSparseImageType >, and itk::CurvatureFlowFunction< TImage >.

template<typename TImageType>
const NeighborhoodScalesType itk::FiniteDifferenceFunction< TImageType >::ComputeNeighborhoodScales ( ) const

Compute the scales that weight the neighborhood during difference operations to properly account for spacing and neighborhood radius

template<typename TImageType>
virtual PixelType itk::FiniteDifferenceFunction< TImageType >::ComputeUpdate ( const NeighborhoodType neighborhood,
void *  globalData,
const FloatOffsetType offset = FloatOffsetType(0.0) 
)
pure virtual

This method is called by a finite difference solver image filter at each pixel that does not lie on a data set boundary. The width of the data set boundary is defined by the width of the neighborhood being evaluated.

The neighborhood argument is the neighborhood data. The globalData argument is a pointer to a data structure that holds values that need to be persistent across calls to this function, but cannot be stored in the function object itself for thread-safety reasons. Examples are values needed to compute the time-step for an iteration of the solver.

See Also
InitializeIteration
ComputeGlobalTimeStep

Implemented in itk::RegionBasedLevelSetFunction< TInputImage, TFeatureImage, TSharedData >, itk::LevelSetFunction< TImageType >, itk::ShapePriorSegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::GPUFiniteDifferenceFunction< TImageType >, itk::GPUFiniteDifferenceFunction< TImage >, and itk::GPUFiniteDifferenceFunction< TDisplacementField >.

template<typename TImageType>
virtual void* itk::FiniteDifferenceFunction< TImageType >::GetGlobalDataPointer ( ) const
pure virtual

Returns a pointer to a global data structure that is passed to this object from the solver at each calculation. The idea is that the solver holds the state of any global values needed to calculate the time step, while the equation object performs the actual calculations.

The global data should also be initialized in this method.

Implemented in itk::AnisotropicDiffusionFunction< TImage >, itk::LevelSetFunction< TImageType >, itk::RegionBasedLevelSetFunction< TInput, TFeature, TSharedData >, itk::RegionBasedLevelSetFunction< TInputImage, TFeatureImage, TSharedData >, itk::VariationalRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::ESMDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::GPUDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::SymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::LevelSetMotionRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::DemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::FastSymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::MeanSquareRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::ShapePriorSegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::VariationalRegistrationFastNCCFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::GPUAnisotropicDiffusionFunction< TImage >, itk::CurvatureFlowFunction< TImage >, and itk::NormalVectorFunctionBase< TSparseImageType >.

template<typename TImageType>
virtual const char* itk::FiniteDifferenceFunction< TImageType >::GetNameOfClass ( ) const
virtual

Run-time type information (and related methods)

Reimplemented from itk::LightObject.

Reimplemented in itk::AnisotropicDiffusionFunction< TImage >, itk::GeodesicActiveContourShapePriorLevelSetFunction< TImageType, TFeatureImageType >, itk::GeodesicActiveContourLevelSetFunction< TImageType, TFeatureImageType >, itk::CurvatureNDAnisotropicDiffusionFunction< TImage >, itk::ScalarChanAndVeseLevelSetFunction< TInputImage, TFeatureImage, TSharedData >, itk::ShapeDetectionLevelSetFunction< TImageType, TFeatureImageType >, itk::RegionBasedLevelSetFunction< TInput, TFeature, TSharedData >, itk::RegionBasedLevelSetFunction< TInputImage, TFeatureImage, TSharedData >, itk::LevelSetFunction< TImageType >, itk::ESMDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::SymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationFastNCCFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::CurvesLevelSetFunction< TImageType, TFeatureImageType >, itk::ScalarRegionBasedLevelSetFunction< TInputImage, TFeatureImage, TSharedData >, itk::VariationalRegistrationNCCFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::GradientNDAnisotropicDiffusionFunction< TImage >, itk::GPUDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VectorThresholdSegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::GPUGradientNDAnisotropicDiffusionFunction< TImage >, itk::LevelSetMotionRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::ThresholdSegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::DemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationDemonsFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::NormalVectorDiffusionFunction< TSparseImageType >, itk::ShapePriorSegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::MeanSquareRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationSSDFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VectorAnisotropicDiffusionFunction< TImage >, itk::ScalarAnisotropicDiffusionFunction< TImage >, itk::FastSymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::LevelSetFunctionWithRefitTerm< TImageType, TSparseImageType >, itk::NormalVectorFunctionBase< TSparseImageType >, itk::VectorCurvatureNDAnisotropicDiffusionFunction< TImage >, itk::VectorGradientNDAnisotropicDiffusionFunction< TImage >, itk::FiniteDifferenceSparseImageFunction< TSparseImageType >, itk::CurvatureFlowFunction< TImage >, itk::SegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::GPUFiniteDifferenceFunction< TImageType >, itk::GPUFiniteDifferenceFunction< TImage >, itk::GPUFiniteDifferenceFunction< TDisplacementField >, itk::MinMaxCurvatureFlowFunction< TImage >, itk::GPUPDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::PDEDeformableRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::CannySegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::LaplacianSegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::GPUAnisotropicDiffusionFunction< TImage >, and itk::GPUScalarAnisotropicDiffusionFunction< TImage >.

template<typename TImageType>
const RadiusType& itk::FiniteDifferenceFunction< TImageType >::GetRadius ( ) const

Returns the radius of the neighborhood this FiniteDifferenceFunction needs to perform its calculations.

template<typename TImageType>
void itk::FiniteDifferenceFunction< TImageType >::GetScaleCoefficients ( PixelRealType  vals[ImageDimension]) const

Returns the current scale coefficients.

template<typename TImageType>
virtual void itk::FiniteDifferenceFunction< TImageType >::InitializeIteration ( )
inlinevirtual

This method allows the function to set its state before each iteration of the finite difference solver (image filter) that uses it. This is a thread-safe time to manipulate the object's state.

An example of how this can be used: the AnisotropicDiffusionFunction class of FiniteDifferenceFunction use this method to pre-calculate an average gradient magnitude across the entire image region. This value is set in the function object and used by the ComputeUpdate() methods that are called at each pixel as a constant.

Reimplemented in itk::GPUDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::ESMDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::LevelSetMotionRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::SymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::DemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::FastSymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::MeanSquareRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationNCCFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::CurvatureNDAnisotropicDiffusionFunction< TImage >, itk::VariationalRegistrationDemonsFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationSSDFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::GradientNDAnisotropicDiffusionFunction< TImage >, itk::GPUGradientNDAnisotropicDiffusionFunction< TImage >, itk::VectorGradientNDAnisotropicDiffusionFunction< TImage >, and itk::VectorCurvatureNDAnisotropicDiffusionFunction< TImage >.

Definition at line 120 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
void itk::FiniteDifferenceFunction< TImageType >::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
overrideprotectedvirtual
template<typename TImageType>
virtual void itk::FiniteDifferenceFunction< TImageType >::ReleaseGlobalDataPointer ( void *  GlobalData) const
pure virtual

When the finite difference solver filter has finished using a global data pointer, it passes it to this method, which frees the memory.

The solver cannot free the memory because it does not know the type to which the pointer points.

Implemented in itk::RegionBasedLevelSetFunction< TInput, TFeature, TSharedData >, itk::RegionBasedLevelSetFunction< TInputImage, TFeatureImage, TSharedData >, itk::LevelSetFunction< TImageType >, itk::AnisotropicDiffusionFunction< TImage >, itk::VariationalRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::ESMDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::GPUDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::LevelSetMotionRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::SymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::DemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::FastSymmetricForcesDemonsRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::ShapePriorSegmentationLevelSetFunction< TImageType, TFeatureImageType >, itk::MeanSquareRegistrationFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::VariationalRegistrationFastNCCFunction< TFixedImage, TMovingImage, TDisplacementField >, itk::GPUAnisotropicDiffusionFunction< TImage >, itk::CurvatureFlowFunction< TImage >, and itk::NormalVectorFunctionBase< TSparseImageType >.

template<typename TImageType>
void itk::FiniteDifferenceFunction< TImageType >::SetRadius ( const RadiusType r)

Sets the radius of the neighborhood this FiniteDifferenceFunction needs to perform its calculations.

template<typename TImageType>
void itk::FiniteDifferenceFunction< TImageType >::SetScaleCoefficients ( PixelRealType  vals[ImageDimension])

Set the ScaleCoefficients for the difference operators. The defaults a 1.0. These can be set to take the image spacing into account.

Member Data Documentation

template<typename TImageType>
constexpr unsigned int itk::FiniteDifferenceFunction< TImageType >::ImageDimension = ImageType::ImageDimension
static

Save image dimension.

Definition at line 87 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
RadiusType itk::FiniteDifferenceFunction< TImageType >::m_Radius
protected

Definition at line 191 of file itkFiniteDifferenceFunction.h.

template<typename TImageType>
PixelRealType itk::FiniteDifferenceFunction< TImageType >::m_ScaleCoefficients[ImageDimension]
protected

Definition at line 192 of file itkFiniteDifferenceFunction.h.


The documentation for this class was generated from the following file: