Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
itk::ShortestPathCostFunction< TInputImageType > Class Template Referenceabstract

Abstract base class for cost functions used by ShortestPathImageFilter. More...

#include <itkShortestPathCostFunction.h>

Inheritance diagram for itk::ShortestPathCostFunction< TInputImageType >:
Collaboration diagram for itk::ShortestPathCostFunction< TInputImageType >:

Public Types

typedef ShortestPathCostFunction Self
 
typedef Object Superclass
 
typedef SmartPointer< Self > Pointer
 
typedef SmartPointer< const Self > ConstPointer
 
typedef ShapedNeighborhoodIterator< TInputImageType > ShapedNeighborhoodIteratorType
 
typedef TInputImageType ImageType
 
typedef TInputImageType::Pointer ImagePointer
 
typedef TInputImageType::ConstPointer ImageConstPointer
 
typedef TInputImageType::PixelType PixelType
 
typedef TInputImageType::IndexType IndexType
 

Public Member Functions

virtual const char * GetClassName () const
 
virtual void SetImage (const TInputImageType *_arg)
 Set the input image on which costs are computed. More...
 
virtual double GetCost (IndexType p1, IndexType p2)=0
 Calculate the cost of transitioning from pixel p1 to pixel p2. More...
 
virtual double GetMinCost ()=0
 Return the minimal possible cost for any transition. More...
 
virtual void Initialize ()=0
 Initialize the cost function. More...
 
void SetStartIndex (const IndexType &index)
 Set the starting index of the path. More...
 
void SetEndIndex (const IndexType &index)
 Set the ending index of the path. More...
 

Protected Member Functions

 ShortestPathCostFunction ()
 
 ~ShortestPathCostFunction () override
 
void PrintSelf (std::ostream &os, Indent indent) const override
 

Protected Attributes

ImageConstPointer m_Image
 The input image used for cost computation. More...
 
IndexType m_StartIndex
 
IndexType m_EndIndex
 Start and end indices defining the path endpoints. More...
 

Detailed Description

template<class TInputImageType>
class itk::ShortestPathCostFunction< TInputImageType >

Abstract base class for cost functions used by ShortestPathImageFilter.

This pure virtual class defines the interface for cost functions that compute the transition cost between two neighboring pixels in an image. Subclasses must implement GetCost(), GetMinCost(), and Initialize() to provide application-specific cost metrics (e.g., gradient-based costs for LiveWire segmentation, or TBSS-based costs for tract definition).

The cost function operates on images of type TInputImageType and is used by ShortestPathImageFilter to find the cheapest path between a start and end index.

Template Parameters
TInputImageTypeThe ITK image type used as input. Must provide PixelType and IndexType typedefs.
See also
ShortestPathImageFilter
ShortestPathCostFunctionLiveWire
ShortestPathCostFunctionTbss

Definition at line 42 of file itkShortestPathCostFunction.h.

Member Typedef Documentation

◆ ConstPointer

template<class TInputImageType >
typedef SmartPointer<const Self> itk::ShortestPathCostFunction< TInputImageType >::ConstPointer

Definition at line 49 of file itkShortestPathCostFunction.h.

◆ ImageConstPointer

template<class TInputImageType >
typedef TInputImageType::ConstPointer itk::ShortestPathCostFunction< TInputImageType >::ImageConstPointer

Definition at line 60 of file itkShortestPathCostFunction.h.

◆ ImagePointer

template<class TInputImageType >
typedef TInputImageType::Pointer itk::ShortestPathCostFunction< TInputImageType >::ImagePointer

Definition at line 59 of file itkShortestPathCostFunction.h.

◆ ImageType

template<class TInputImageType >
typedef TInputImageType itk::ShortestPathCostFunction< TInputImageType >::ImageType

Type definition for the input image.

Definition at line 56 of file itkShortestPathCostFunction.h.

◆ IndexType

template<class TInputImageType >
typedef TInputImageType::IndexType itk::ShortestPathCostFunction< TInputImageType >::IndexType

Definition at line 62 of file itkShortestPathCostFunction.h.

◆ PixelType

template<class TInputImageType >
typedef TInputImageType::PixelType itk::ShortestPathCostFunction< TInputImageType >::PixelType

Definition at line 61 of file itkShortestPathCostFunction.h.

◆ Pointer

template<class TInputImageType >
typedef SmartPointer<Self> itk::ShortestPathCostFunction< TInputImageType >::Pointer

Definition at line 48 of file itkShortestPathCostFunction.h.

◆ Self

template<class TInputImageType >
typedef ShortestPathCostFunction itk::ShortestPathCostFunction< TInputImageType >::Self

Standard class typedefs.

Definition at line 46 of file itkShortestPathCostFunction.h.

◆ ShapedNeighborhoodIteratorType

template<class TInputImageType >
typedef ShapedNeighborhoodIterator<TInputImageType> itk::ShortestPathCostFunction< TInputImageType >::ShapedNeighborhoodIteratorType

Definition at line 50 of file itkShortestPathCostFunction.h.

◆ Superclass

template<class TInputImageType >
typedef Object itk::ShortestPathCostFunction< TInputImageType >::Superclass

Definition at line 47 of file itkShortestPathCostFunction.h.

Constructor & Destructor Documentation

◆ ShortestPathCostFunction()

template<class TInputImageType >
itk::ShortestPathCostFunction< TInputImageType >::ShortestPathCostFunction ( )
inlineprotected

Definition at line 111 of file itkShortestPathCostFunction.h.

◆ ~ShortestPathCostFunction()

template<class TInputImageType >
itk::ShortestPathCostFunction< TInputImageType >::~ShortestPathCostFunction ( )
inlineoverrideprotected

Definition at line 112 of file itkShortestPathCostFunction.h.

Member Function Documentation

◆ GetClassName()

template<class TInputImageType >
virtual const char* itk::ShortestPathCostFunction< TInputImageType >::GetClassName ( ) const
virtual

Run-time type information (and related methods).

Reimplemented in itk::ShortestPathCostFunctionTbss< TInputImageType >, and itk::ShortestPathCostFunctionLiveWire< TInputImageType >.

◆ GetCost()

template<class TInputImageType >
virtual double itk::ShortestPathCostFunction< TInputImageType >::GetCost ( IndexType  p1,
IndexType  p2 
)
pure virtual

Calculate the cost of transitioning from pixel p1 to pixel p2.

Parameters
[in]p1The index of the source pixel.
[in]p2The index of the destination pixel (a neighbor of p1).
Returns
The cost of moving from p1 to p2. Lower values indicate cheaper transitions.

Implemented in itk::ShortestPathCostFunctionTbss< TInputImageType >, and itk::ShortestPathCostFunctionLiveWire< TInputImageType >.

◆ GetMinCost()

template<class TInputImageType >
virtual double itk::ShortestPathCostFunction< TInputImageType >::GetMinCost ( )
pure virtual

Return the minimal possible cost for any transition.

This lower bound is required by the A* search heuristic. If the return value is 0, the algorithm degrades to Dijkstra's algorithm.

Returns
The minimum possible transition cost.

Implemented in itk::ShortestPathCostFunctionTbss< TInputImageType >, and itk::ShortestPathCostFunctionLiveWire< TInputImageType >.

◆ Initialize()

template<class TInputImageType >
virtual void itk::ShortestPathCostFunction< TInputImageType >::Initialize ( )
pure virtual

Initialize the cost function.

Called before the shortest path search begins. Subclasses should perform any required precomputation (e.g., computing gradient images).

Precondition
The input image must have been set via SetImage().

Implemented in itk::ShortestPathCostFunctionTbss< TInputImageType >, and itk::ShortestPathCostFunctionLiveWire< TInputImageType >.

◆ PrintSelf()

template<class TInputImageType >
void itk::ShortestPathCostFunction< TInputImageType >::PrintSelf ( std::ostream &  os,
Indent  indent 
) const
overrideprotected

◆ SetEndIndex()

template<class TInputImageType >
void itk::ShortestPathCostFunction< TInputImageType >::SetEndIndex ( const IndexType &  index)

Set the ending index of the path.

Parameters
[in]indexThe image index where the path ends.

◆ SetImage()

template<class TInputImageType >
virtual void itk::ShortestPathCostFunction< TInputImageType >::SetImage ( const TInputImageType *  _arg)
virtual

Set the input image on which costs are computed.

Reimplemented in itk::ShortestPathCostFunctionLiveWire< TInputImageType >.

◆ SetStartIndex()

template<class TInputImageType >
void itk::ShortestPathCostFunction< TInputImageType >::SetStartIndex ( const IndexType &  index)

Set the starting index of the path.

Parameters
[in]indexThe image index where the path begins.

Member Data Documentation

◆ m_EndIndex

template<class TInputImageType >
IndexType itk::ShortestPathCostFunction< TInputImageType >::m_EndIndex
protected

Start and end indices defining the path endpoints.

Definition at line 115 of file itkShortestPathCostFunction.h.

◆ m_Image

template<class TInputImageType >
ImageConstPointer itk::ShortestPathCostFunction< TInputImageType >::m_Image
protected

The input image used for cost computation.

Definition at line 114 of file itkShortestPathCostFunction.h.

◆ m_StartIndex

template<class TInputImageType >
IndexType itk::ShortestPathCostFunction< TInputImageType >::m_StartIndex
protected

Definition at line 115 of file itkShortestPathCostFunction.h.


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