Medical Imaging Interaction Toolkit  2018.4.99-12ad79a3
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 {
21  // \brief this is a pure virtual superclass for all cost functions used in itkShortestPathImageFilter
22  template <class TInputImageType>
23  class ShortestPathCostFunction : public Object
24  {
25  public:
28  typedef Object Superclass;
31  typedef ShapedNeighborhoodIterator<TInputImageType> ShapedNeighborhoodIteratorType;
32 
34  itkTypeMacro(ShortestPathCostFunction, Object);
35 
37  typedef TInputImageType ImageType;
38 
39  // More typdefs for convenience
40  typedef typename TInputImageType::Pointer ImagePointer;
41  typedef typename TInputImageType::ConstPointer ImageConstPointer;
43  typedef typename TInputImageType::IndexType IndexType;
44 
45  // \brief Set the input image.
46  itkSetConstObjectMacro(Image, TInputImageType);
47 
48  // \brief Calculate the cost for going from pixel p1 to pixel p2
49  virtual double GetCost(IndexType p1, IndexType p2) = 0;
50 
51  // \brief Return the minimal possible cost (needed for A*)
52  virtual double GetMinCost() = 0;
53 
54  // \brief Initialize the metric
55  virtual void Initialize() = 0;
56 
57  // \brief Set the starting index of a path
58  void SetStartIndex(const IndexType &index);
59 
60  // \brief Set the ending index of a path
61  void SetEndIndex(const IndexType &index);
62 
63  protected:
66  void PrintSelf(std::ostream &os, Indent indent) const override;
67  ImageConstPointer m_Image;
69 
70  private:
71  ShortestPathCostFunction(const Self &); // purposely not implemented
72  void operator=(const Self &); // purposely not implemented
73  };
74 
75 } // end namespace itk
76 
78 
79 #endif /* __itkShortestPathCostFunction_h */
TInputImageType::IndexType IndexType
SmartPointer< const Self > ConstPointer
void SetEndIndex(const IndexType &index)
class ITK_EXPORT Image
virtual double GetMinCost()=0
TInputImageType::ConstPointer ImageConstPointer
ShapedNeighborhoodIterator< TInputImageType > ShapedNeighborhoodIteratorType
unsigned short PixelType
void SetStartIndex(const IndexType &index)
TInputImageType::PixelType PixelType
void PrintSelf(std::ostream &os, Indent indent) const override
virtual double GetCost(IndexType p1, IndexType p2)=0