Medical Imaging Interaction Toolkit  2024.12.99-0da743f6
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 
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::ShortestPathCostFunctionLiveWire::FloatImageType
itk::Image< float, 2 > FloatImageType
Definition: itkShortestPathCostFunctionLiveWire.h:58
itk::ShortestPathCostFunctionLiveWire::OutputPixelType
itk::CovariantVector< ComponentType, 2 > OutputPixelType
Definition: itkShortestPathCostFunctionLiveWire.h:61
itk::ShortestPathCostFunctionLiveWire::endValue
Superclass::PixelType endValue
Definition: itkShortestPathCostFunctionLiveWire.h:141
itk::ShortestPathCostFunctionLiveWire::GetGradientImage
const VectorOutputImageType * GetGradientImage()
Definition: itkShortestPathCostFunctionLiveWire.h:123
itk::ShortestPathCostFunctionLiveWire::RegionType
itk::ImageRegion< 2 > RegionType
Definition: itkShortestPathCostFunctionLiveWire.h:66
itk::ShortestPathCostFunctionLiveWire::val
Superclass::PixelType val
Definition: itkShortestPathCostFunctionLiveWire.h:138
itk::ShortestPathCostFunctionLiveWire::m_CostMap
std::map< int, int > m_CostMap
Definition: itkShortestPathCostFunctionLiveWire.h:149
itk::ShortestPathCostFunctionLiveWire::GetGradientMagnitudeImage
const FloatImageType * GetGradientMagnitudeImage()
Definition: itkShortestPathCostFunctionLiveWire.h:121
itk::ShortestPathCostFunctionLiveWire::m_MaxMapCosts
double m_MaxMapCosts
Definition: itkShortestPathCostFunctionLiveWire.h:153
itk::ShortestPathCostFunctionLiveWire
Cost function for LiveWire purposes. Specific features are considered to calculate cummulative costs ...
Definition: itkShortestPathCostFunctionLiveWire.h:40
itk::ShortestPathCostFunctionLiveWire::m_MinCosts
double m_MinCosts
Definition: itkShortestPathCostFunctionLiveWire.h:134
itk::ShortestPathCostFunctionLiveWire::ComponentType
float ComponentType
Definition: itkShortestPathCostFunctionLiveWire.h:60
itk::ShortestPathCostFunctionLiveWire::SetCostMapMaximum
void SetCostMapMaximum(double max)
Set the maximum of the dynamic cost map to save computation time.
Definition: itkShortestPathCostFunctionLiveWire.h:103
itk::SmartPointer< Self >
itkShortestPathCostFunction.h
itk::ShortestPathCostFunctionLiveWire::Constants
Constants
Definition: itkShortestPathCostFunctionLiveWire.h:104
itk::ShortestPathCostFunctionLiveWire::m_EdgeImage
FloatImageType::Pointer m_EdgeImage
Definition: itkShortestPathCostFunctionLiveWire.h:130
itk::ShortestPathCostFunctionLiveWire::Superclass
ShortestPathCostFunction< TInputImageType > Superclass
Definition: itkShortestPathCostFunctionLiveWire.h:45
itk::ShortestPathCostFunctionLiveWire::Pointer
SmartPointer< Self > Pointer
Definition: itkShortestPathCostFunctionLiveWire.h:46
itk::ShortestPathCostFunctionLiveWire::UnsignedCharImageType
itk::Image< unsigned char, 2 > UnsignedCharImageType
Definition: itkShortestPathCostFunctionLiveWire.h:55
itk::ShortestPathCostFunctionLiveWire::Self
ShortestPathCostFunctionLiveWire Self
Definition: itkShortestPathCostFunctionLiveWire.h:44
itk::ShortestPathCostFunctionLiveWire::GetEdgeImage
const FloatImageType * GetEdgeImage()
Definition: itkShortestPathCostFunctionLiveWire.h:122
itk::ShortestPathCostFunctionLiveWire::SetUseCostMap
void SetUseCostMap(bool useCostMap)
Definition: itkShortestPathCostFunctionLiveWire.h:99
itk::ShortestPathCostFunctionLiveWire::m_UseCostMap
bool m_UseCostMap
Definition: itkShortestPathCostFunctionLiveWire.h:151
itk::ShortestPathCostFunction::PixelType
TInputImageType::PixelType PixelType
Definition: itkShortestPathCostFunction.h:42
itk::ShortestPathCostFunctionLiveWire::m_GradientImage
VectorOutputImageType::Pointer m_GradientImage
Definition: itkShortestPathCostFunctionLiveWire.h:132
itk::ShortestPathCostFunction::IndexType
TInputImageType::IndexType IndexType
Definition: itkShortestPathCostFunction.h:43
itk::ShortestPathCostFunctionLiveWire::GetMaskImage
const UnsignedCharImageType * GetMaskImage()
Definition: itkShortestPathCostFunctionLiveWire.h:120
itk::ShortestPathCostFunctionLiveWire::ConstPointer
SmartPointer< const Self > ConstPointer
Definition: itkShortestPathCostFunctionLiveWire.h:47
itk::ShortestPathCostFunctionLiveWire::VectorOutputImageType
itk::Image< OutputPixelType, 2 > VectorOutputImageType
Definition: itkShortestPathCostFunctionLiveWire.h:62
itk::ShortestPathCostFunctionLiveWire::IndexType
TInputImageType::IndexType IndexType
Definition: itkShortestPathCostFunctionLiveWire.h:64
itk::ShortestPathCostFunctionLiveWire::ConstIteratorType
itk::ImageRegionConstIterator< TInputImageType > ConstIteratorType
Definition: itkShortestPathCostFunctionLiveWire.h:48
itk::ShortestPathCostFunctionLiveWire::m_Initialized
bool m_Initialized
Definition: itkShortestPathCostFunctionLiveWire.h:147
itk::ShortestPathCostFunctionLiveWire::startValue
Superclass::PixelType startValue
Definition: itkShortestPathCostFunctionLiveWire.h:140
itk
SET FUNCTIONS.
Definition: itkIntelligentBinaryClosingFilter.h:30
itk::ShortestPathCostFunctionLiveWire::m_GradientMax
double m_GradientMax
Definition: itkShortestPathCostFunctionLiveWire.h:143
itk::ShortestPathCostFunctionLiveWire::m_UseRepulsivePoints
bool m_UseRepulsivePoints
Definition: itkShortestPathCostFunctionLiveWire.h:136
itk::ShortestPathCostFunctionLiveWire::m_RequestedRegion
RegionType m_RequestedRegion
Definition: itkShortestPathCostFunctionLiveWire.h:145
itk::ShortestPathCostFunctionLiveWire::SetDynamicCostMap
void SetDynamicCostMap(std::map< int, int > &costMap)
Definition: itkShortestPathCostFunctionLiveWire.h:91
itk::ShortestPathCostFunction
Definition: itkShortestPathCostFunction.h:23
itk::ShortestPathCostFunctionLiveWire::ImageType
TInputImageType ImageType
Definition: itkShortestPathCostFunctionLiveWire.h:65
itk::ShortestPathCostFunctionLiveWire::~ShortestPathCostFunctionLiveWire
~ShortestPathCostFunctionLiveWire() override
Definition: itkShortestPathCostFunctionLiveWire.h:127
itk::ShortestPathCostFunctionLiveWire::m_MaskImage
UnsignedCharImageType::Pointer m_MaskImage
Definition: itkShortestPathCostFunctionLiveWire.h:131