Medical Imaging Interaction Toolkit  2021.02.99-e55a5d2f
Medical Imaging Interaction Toolkit
itkShortestPathCostFunctionLiveWire.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 
13 #ifndef __itkShortestPathCostFunctionLiveWire_h
14 #define __itkShortestPathCostFunctionLiveWire_h
15 
17 
18 #include "itkImageRegionConstIterator.h"
19 
20 namespace itk
21 {
39  template <class TInputImageType>
40  class ITK_EXPORT ShortestPathCostFunctionLiveWire : public ShortestPathCostFunction<TInputImageType>
41  {
42  public:
48  typedef itk::ImageRegionConstIterator<TInputImageType> ConstIteratorType;
49 
51  itkFactorylessNewMacro(Self);
52  itkCloneMacro(Self);
53 
56 
57  typedef itk::Image<unsigned char, 2> UnsignedCharImageType;
58  typedef itk::Image<float, 2> FloatImageType;
59 
60  typedef float ComponentType;
61  typedef itk::CovariantVector<ComponentType, 2> OutputPixelType;
62  typedef itk::Image<OutputPixelType, 2> VectorOutputImageType;
63 
64  typedef typename TInputImageType::IndexType IndexType;
65  typedef TInputImageType ImageType;
66  typedef itk::ImageRegion<2> RegionType;
67 
69  double GetCost(IndexType p1, IndexType p2) override;
70 
72  double GetMinCost() override;
73 
75  void Initialize() override;
76 
78  virtual void AddRepulsivePoint(const IndexType &index);
79 
81  virtual void RemoveRepulsivePoint(const IndexType &index);
82 
84  virtual void ClearRepulsivePoints();
85 
86  itkSetMacro(RequestedRegion, RegionType);
87  itkGetMacro(RequestedRegion, RegionType);
88 
89  void SetImage(const TInputImageType *_arg) override;
90 
91  void SetDynamicCostMap(std::map<int, int> &costMap)
92  {
93  this->m_CostMap = costMap;
94  this->m_UseCostMap = true;
95  this->m_MaxMapCosts = -1;
96  this->Modified();
97  }
98 
99  void SetUseCostMap(bool useCostMap) { this->m_UseCostMap = useCostMap; }
103  void SetCostMapMaximum(double max) { this->m_MaxMapCosts = max; }
105  {
106  MAPSCALEFACTOR = 10
107  };
108 
118  static double Gaussian(double x, double xOfGaussian, double yOfGaussian);
119 
120  const UnsignedCharImageType *GetMaskImage() { return this->m_MaskImage.GetPointer(); };
121  const FloatImageType *GetGradientMagnitudeImage() { return this->m_GradientMagnitudeImage.GetPointer(); };
122  const FloatImageType *GetEdgeImage() { return this->m_EdgeImage.GetPointer(); };
123  const VectorOutputImageType *GetGradientImage() { return this->m_GradientImage.GetPointer(); };
124  protected:
126 
128 
129  FloatImageType::Pointer m_GradientMagnitudeImage;
130  FloatImageType::Pointer m_EdgeImage;
131  UnsignedCharImageType::Pointer m_MaskImage;
132  VectorOutputImageType::Pointer m_GradientImage;
133 
134  double m_MinCosts;
135 
137 
139 
142 
144 
145  RegionType m_RequestedRegion;
146 
148 
149  std::map<int, int> m_CostMap;
150 
152 
154 
155  private:
156  double SigmoidFunction(double I, double max, double min, double alpha, double beta);
157  };
158 
159 } // end namespace itk
160 
161 #ifndef ITK_MANUAL_INSTANTIATION
162 #include "itkShortestPathCostFunctionLiveWire.txx"
163 #endif
164 
165 #endif /* __itkShortestPathCostFunctionLiveWire_h */
itk::ImageRegionConstIterator< TInputImageType > ConstIteratorType
Cost function for LiveWire purposes. Specific features are considered to calculate cummulative costs ...
void SetDynamicCostMap(std::map< int, int > &costMap)
itk::CovariantVector< ComponentType, 2 > OutputPixelType
TInputImageType::PixelType PixelType
ShortestPathCostFunction< TInputImageType > Superclass
void SetCostMapMaximum(double max)
Set the maximum of the dynamic cost map to save computation time.