Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
itkShortestPathCostFunction.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 #ifndef itkShortestPathCostFunction_h
13 #define itkShortestPathCostFunction_h
14 
15 #include <itkObject.h>
16 #include <itkObjectFactory.h>
17 #include <itkShapedNeighborhoodIterator.h>
18 
19 namespace itk
20 {
41  template <class TInputImageType>
42  class ShortestPathCostFunction : public Object
43  {
44  public:
47  typedef Object Superclass;
50  typedef ShapedNeighborhoodIterator<TInputImageType> ShapedNeighborhoodIteratorType;
51 
53  itkTypeMacro(ShortestPathCostFunction, Object);
54 
56  typedef TInputImageType ImageType;
57 
58  // More typedefs for convenience
59  typedef typename TInputImageType::Pointer ImagePointer;
60  typedef typename TInputImageType::ConstPointer ImageConstPointer;
61  typedef typename TInputImageType::PixelType PixelType;
62  typedef typename TInputImageType::IndexType IndexType;
63 
65  itkSetConstObjectMacro(Image, TInputImageType);
66 
74  virtual double GetCost(IndexType p1, IndexType p2) = 0;
75 
84  virtual double GetMinCost() = 0;
85 
94  virtual void Initialize() = 0;
95 
101  void SetStartIndex(const IndexType &index);
102 
108  void SetEndIndex(const IndexType &index);
109 
110  protected:
113  void PrintSelf(std::ostream &os, Indent indent) const override;
116 
117  private:
118  ShortestPathCostFunction(const Self &); // purposely not implemented
119  void operator=(const Self &); // purposely not implemented
120  };
121 
122 } // end namespace itk
123 
124 #include <itkShortestPathCostFunction.tpp>
125 
126 #endif /* itkShortestPathCostFunction_h */
Abstract base class for cost functions used by ShortestPathImageFilter.
virtual void Initialize()=0
Initialize the cost function.
ShapedNeighborhoodIterator< TInputImageType > ShapedNeighborhoodIteratorType
TInputImageType::ConstPointer ImageConstPointer
TInputImageType::IndexType IndexType
void SetStartIndex(const IndexType &index)
Set the starting index of the path.
virtual double GetMinCost()=0
Return the minimal possible cost for any transition.
void SetEndIndex(const IndexType &index)
Set the ending index of the path.
SmartPointer< const Self > ConstPointer
IndexType m_EndIndex
Start and end indices defining the path endpoints.
TInputImageType::PixelType PixelType
virtual double GetCost(IndexType p1, IndexType p2)=0
Calculate the cost of transitioning from pixel p1 to pixel p2.
void PrintSelf(std::ostream &os, Indent indent) const override
ImageConstPointer m_Image
The input image used for cost computation.
class ITK_EXPORT Image