VMTK
vtkvmtkVesselEnhancingDiffusion3DImageFilter.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkVesselEnhancingDiffusion3DImageFilter.h,v $
5 Language: C++
6 
7  Copyright (c) Luca Antiga, David Steinman. All rights reserved.
8  See LICENSE file for details.
9 
10  Portions of this code are covered under the VTK copyright.
11  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
12  for details.
13 
14  Portions of this code are covered under the ITK copyright.
15  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm
16  for details.
17 
18  This software is distributed WITHOUT ANY WARRANTY; without even
19  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
20  PURPOSE. See the above copyright notices for more information.
21 
22 =========================================================================*/
23 
33 #ifndef __vtkvmtkVesselEnhancingDiffusion3DImageFilter_h
34 #define __vtkvmtkVesselEnhancingDiffusion3DImageFilter_h
35 
36 
37 #include "vtkvmtkITKImageToImageFilterFF.h"
38 #include "itkVesselEnhancingDiffusion3DImageFilter.h"
39 #include "vtkvmtkWin32Header.h"
40 #include "vtkVersion.h"
41 
42 class VTK_VMTK_SEGMENTATION_EXPORT vtkvmtkVesselEnhancingDiffusion3DImageFilter : public vtkvmtkITKImageToImageFilterFF
43 {
44  public:
46  vtkTypeMacro(vtkvmtkVesselEnhancingDiffusion3DImageFilter, vtkvmtkITKImageToImageFilterFF);
47 
48  vtkSetMacro(SigmaMin,double);
49  vtkGetMacro(SigmaMin,double);
50 
51  vtkSetMacro(SigmaMax,double);
52  vtkGetMacro(SigmaMax,double);
53 
54  vtkSetMacro(NumberOfSigmaSteps,int);
55  vtkGetMacro(NumberOfSigmaSteps,int);
56 
58  {
59  this->SigmaStepMethod = EQUISPACED_STEPS;
60  }
61 
63  {
64  this->SigmaStepMethod = LOGARITHMIC_STEPS;
65  }
66 
67  void SetTimeStep(double value)
68  {
69  DelegateITKInputMacro(SetTimeStep,value);
70  }
71 
72  void SetEpsilon(double value)
73  {
74  DelegateITKInputMacro(SetEpsilon,value);
75  }
76 
77  void SetOmega(double value)
78  {
79  DelegateITKInputMacro(SetOmega,value);
80  }
81 
82  void SetSensitivity(double value)
83  {
84  DelegateITKInputMacro(SetSensitivity,value);
85  }
86 
87  void SetNumberOfIterations(int value)
88  {
89  DelegateITKInputMacro(SetIterations,value);
90  }
91 
92  void SetAlpha(double value)
93  {
94  DelegateITKInputMacro(SetAlpha,value);
95  }
96 
97  void SetBeta(double value)
98  {
99  DelegateITKInputMacro(SetBeta,value);
100  }
101 
102  void SetGamma(double value)
103  {
104  DelegateITKInputMacro(SetGamma,value);
105  }
106 
107  void SetRecalculateVesselness(int value)
108  {
109  DelegateITKInputMacro(SetRecalculateVesselness,value);
110  }
111 
112  double ComputeSigmaValue(int scaleLevel)
113  {
114  double sigmaValue;
115 
116  if (this->NumberOfSigmaSteps < 2)
117  {
118  return this->SigmaMin;
119  }
120 
121  switch (this->SigmaStepMethod)
122  {
123  case EQUISPACED_STEPS:
124  {
125  double stepSize = ( SigmaMax - SigmaMin ) / (NumberOfSigmaSteps-1);
126  if (stepSize < 1e-10)
127  {
128  stepSize = 1e-10;
129  }
130  sigmaValue = SigmaMin + stepSize * scaleLevel;
131  break;
132  }
133  case LOGARITHMIC_STEPS:
134  {
135  double stepSize = ( vcl_log(SigmaMax) - vcl_log(SigmaMin) ) / (NumberOfSigmaSteps-1);
136  if (stepSize < 1e-10)
137  {
138  stepSize = 1e-10;
139  }
140  sigmaValue = vcl_exp( vcl_log (SigmaMin) + stepSize * scaleLevel);
141  break;
142  }
143  default:
144  vtkErrorMacro("Error: undefined sigma step method.");
145  sigmaValue = 0.0;
146  break;
147  }
148 
149  return sigmaValue;
150  }
151 
152  void Update()
153  {
154  std::vector<float> scales;
155  for (int i=0; i<this->NumberOfSigmaSteps; i++)
156  {
157  scales.push_back(this->ComputeSigmaValue(i));
158  }
159  this->GetImageFilterPointer()->SetScales(scales);
160 #if (VTK_MAJOR_VERSION <= 5)
161  if (this->GetOutput(0))
162  {
163  this->GetOutput(0)->Update();
164  if ( this->GetOutput(0)->GetSource() )
165  {
166  // this->SetErrorCode( this->GetOutput(0)->GetSource()->GetErrorCode() );
167  }
168  }
169 #endif
170  }
171 
172 //BTX
173  enum
174  {
176  LOGARITHMIC_STEPS
177  };
178 //ETX
179 
180 protected:
181  //BTX
182  typedef itk::VesselEnhancingDiffusion3DImageFilter<Superclass::InputImageType::PixelType> ImageFilterType;
183 
185  {
186  this->SigmaMin = 0.0;
187  this->SigmaMax = 0.0;
188  this->NumberOfSigmaSteps = 0;
189  this->SigmaStepMethod = EQUISPACED_STEPS;
190 
191  this->GetImageFilterPointer()->SetDefaultPars();
192  }
193 
195  ImageFilterType* GetImageFilterPointer() { return dynamic_cast<ImageFilterType*>(m_Filter.GetPointer()); }
196  //ETX
197 
198  double SigmaMin;
199  double SigmaMax;
202 
203 private:
205  void operator=(const vtkvmtkVesselEnhancingDiffusion3DImageFilter&); // Not implemented.
206 };
207 
208 #endif
209 
210 
211 
212 
itk::VesselEnhancingDiffusion3DImageFilter< Superclass::InputImageType::PixelType > ImageFilterType
Wrapper class around itk::VesselEnhancingDiffusion3DImageFilter.