Orfeo Toolbox  3.16
itkRegionBasedLevelSetFunction.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkRegionBasedLevelSetFunction.h,v $
5  Language: C++
6  Date: $Date: 2010-02-24 22:42:16 $
7  Version: $Revision: 1.19 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __itkRegionBasedLevelSetFunction_h
19 #define __itkRegionBasedLevelSetFunction_h
20 
23 #include "vnl/vnl_matrix_fixed.h"
24 
25 namespace itk {
26 
63 template < class TInput, // LevelSetImageType
64  class TFeature, // FeatureImageType
65  class TSharedData >
68 {
69 public:
75 
76  itkStaticConstMacro(ImageDimension, unsigned int, Superclass::ImageDimension);
77 
78  // itkNewMacro() is purposely not provided since this is an abstract class.
79 
82 
84  typedef double TimeStepType;
85  typedef typename Superclass::ImageType ImageType;
86  typedef typename Superclass::PixelType PixelType;
88  typedef typename Superclass::RadiusType RadiusType;
89  typedef typename Superclass::NeighborhoodType NeighborhoodType;
90  typedef typename Superclass::NeighborhoodScalesType NeighborhoodScalesType;
91  typedef typename Superclass::FloatOffsetType FloatOffsetType;
94 
95  /* This structure is derived from LevelSetFunction and stores intermediate
96  values for computing time step sizes */
98  {
100  {
101  ScalarValueType null_value = NumericTraits<ScalarValueType>::Zero;
102 
103  m_MaxCurvatureChange = null_value;
104  m_MaxAdvectionChange = null_value;
105  m_MaxGlobalChange = null_value;
106  }
107 
109 
110  vnl_matrix_fixed<ScalarValueType,
111  itkGetStaticConstMacro(ImageDimension),
112  itkGetStaticConstMacro(ImageDimension)> m_dxy;
113 
114  ScalarValueType m_dx[itkGetStaticConstMacro(ImageDimension)];
115 
116  ScalarValueType m_dx_forward[ itkGetStaticConstMacro( ImageDimension ) ];
117  ScalarValueType m_dx_backward[ itkGetStaticConstMacro( ImageDimension ) ];
118 
121 
125  };
126 
127 
128  typedef TInput InputImageType;
129  typedef typename InputImageType::ConstPointer InputImageConstPointer;
130  typedef typename InputImageType::Pointer InputImagePointer;
131  typedef typename InputImageType::PixelType InputPixelType;
132  typedef typename InputImageType::IndexType InputIndexType;
133  typedef typename InputImageType::IndexValueType InputIndexValueType;
134  typedef typename InputImageType::SizeType InputSizeType;
135  typedef typename InputImageType::SizeValueType InputSizeValueType;
136  typedef typename InputImageType::RegionType InputRegionType;
137  typedef typename InputImageType::PointType InputPointType;
138 
139  typedef TFeature FeatureImageType;
140  typedef typename FeatureImageType::ConstPointer FeatureImageConstPointer;
141  typedef typename FeatureImageType::PixelType FeaturePixelType;
142  typedef typename FeatureImageType::IndexType FeatureIndexType;
143  typedef typename FeatureImageType::SpacingType FeatureSpacingType;
144  typedef typename FeatureImageType::OffsetType FeatureOffsetType;
145 
146  typedef TSharedData SharedDataType;
147  typedef typename SharedDataType::Pointer SharedDataPointer;
148 
151 
152  void SetDomainFunction( const HeavisideFunctionType * f )
153  {
154  this->m_DomainFunction = f;
155  }
156 
157  virtual void Initialize(const RadiusType &r)
158  {
159  this->SetRadius(r);
160 
161  // Dummy neighborhood.
162  NeighborhoodType it;
163  it.SetRadius( r );
164 
165  // Find the center index of the neighborhood.
166  m_Center = it.Size() / 2;
167 
168  // Get the stride length for each axis.
169  for(unsigned int i = 0; i < ImageDimension; i++)
170  {
171  m_xStride[i] = it.GetStride(i);
172  }
173  }
174 
175 
176  void SetSharedData( SharedDataPointer sharedDataIn )
177  {
178  this->m_SharedData = sharedDataIn;
179  }
180 
181  void UpdateSharedData( bool forceUpdate );
182 
183  void *GetGlobalDataPointer() const
184  {
185  return new GlobalDataStruct;
186  }
187 
188  TimeStepType ComputeGlobalTimeStep(void *GlobalData) const;
189 
191  virtual PixelType ComputeUpdate(const NeighborhoodType &neighborhood,
192  void *globalData, const FloatOffsetType& = FloatOffsetType(0.0));
193 
194  void SetInitialImage(InputImageType *f)
195  {
196  m_InitialImage = f;
197  }
198 
199  virtual const FeatureImageType *GetFeatureImage() const
200  { return m_FeatureImage.GetPointer(); }
201  virtual void SetFeatureImage(const FeatureImageType *f)
202  {
203  m_FeatureImage = f;
204 
205  FeatureSpacingType spacing = m_FeatureImage->GetSpacing();
206  for(unsigned int i = 0; i < ImageDimension; i++)
207  {
208  this->m_InvSpacing[i] = 1/spacing[i];
209  }
210  }
211 
213  virtual VectorType AdvectionField(const NeighborhoodType &,
214  const FloatOffsetType &, GlobalDataStruct * = 0) const
215  { return this->m_ZeroVectorConstant; }
216 
218  void SetAreaWeight( const ScalarValueType& nu)
219  { this->m_AreaWeight = nu; }
220  ScalarValueType GetAreaWeight() const
221  { return this->m_AreaWeight; }
222 
224  void SetLambda1( const ScalarValueType& lambda1 )
225  { this->m_Lambda1 = lambda1; }
226  ScalarValueType GetLambda1() const
227  { return this->m_Lambda1; }
228 
230  void SetLambda2( const ScalarValueType& lambda2 )
231  { this->m_Lambda2 = lambda2; }
232  ScalarValueType GetLambda2() const
233  { return this->m_Lambda2; }
234 
236  void SetOverlapPenaltyWeight( const ScalarValueType& gamma )
237  { this->m_OverlapPenaltyWeight = gamma; }
238  ScalarValueType GetOverlapPenaltyWeight() const
239  { return this->m_OverlapPenaltyWeight; }
240 
242  virtual void SetCurvatureWeight(const ScalarValueType c)
243  { m_CurvatureWeight = c; }
244  ScalarValueType GetCurvatureWeight() const
245  { return m_CurvatureWeight; }
246 
247  void SetAdvectionWeight( const ScalarValueType& iA)
248  { this->m_AdvectionWeight = iA; }
249  ScalarValueType GetAdvectionWeight() const
250  { return this->m_AdvectionWeight; }
251 
253  void SetReinitializationSmoothingWeight(const ScalarValueType c)
254  { m_ReinitializationSmoothingWeight = c; }
255  ScalarValueType GetReinitializationSmoothingWeight() const
256  { return m_ReinitializationSmoothingWeight; }
257 
259  void SetVolumeMatchingWeight( const ScalarValueType& tau )
260  { this->m_VolumeMatchingWeight = tau; }
261  ScalarValueType GetVolumeMatchingWeight() const
262  { return this->m_VolumeMatchingWeight; }
263 
265  void SetVolume( const ScalarValueType& volume )
266  { this->m_Volume = volume; }
267  ScalarValueType GetVolume() const
268  { return this->m_Volume; }
269 
271  void SetFunctionId( const unsigned int& iFid )
272  { this->m_FunctionId = iFid; }
273 
274  virtual void ReleaseGlobalDataPointer(void *GlobalData) const
275  { delete (GlobalDataStruct *) GlobalData; }
276 
277  virtual ScalarValueType ComputeCurvature(const NeighborhoodType &,
278  const FloatOffsetType &, GlobalDataStruct *gd );
279 
282  virtual ScalarValueType LaplacianSmoothingSpeed(
283  const NeighborhoodType &,
284  const FloatOffsetType &, GlobalDataStruct * = 0) const
285  { return NumericTraits<ScalarValueType>::One; }
286 
289  virtual ScalarValueType CurvatureSpeed(const NeighborhoodType &,
290  const FloatOffsetType &, GlobalDataStruct * = 0
291  ) const
292  { return NumericTraits<ScalarValueType>::One; }
293 
298  virtual void CalculateAdvectionImage() {}
299 
300 protected:
301 
304 
307 
310 
313 
316 
319 
322 
325 
328 
331 
334 
336 
339 
340  unsigned int m_FunctionId;
341 
342  std::slice x_slice[itkGetStaticConstMacro(ImageDimension)];
343  ::size_t m_Center;
344  ::size_t m_xStride[itkGetStaticConstMacro(ImageDimension)];
345  double m_InvSpacing[itkGetStaticConstMacro(ImageDimension)];
346 
347  static double m_WaveDT;
348  static double m_DT;
349 
350  void ComputeHImage();
351 
354  ScalarValueType ComputeGlobalTerm(
355  const ScalarValueType& imagePixel,
356  const InputIndexType& inputIndex );
357 
362  virtual ScalarValueType ComputeInternalTerm(const FeaturePixelType& iValue,
363  const FeatureIndexType& iIdx ) = 0;
364 
370  virtual ScalarValueType ComputeExternalTerm(const FeaturePixelType& iValue,
371  const FeatureIndexType& iIdx ) = 0;
372 
377  virtual ScalarValueType ComputeOverlapParameters( const FeatureIndexType& featIndex,
378  ScalarValueType& pr ) = 0;
379 
384  ScalarValueType ComputeVolumeRegularizationTerm( );
385 
399  ScalarValueType ComputeLaplacian( GlobalDataStruct *gd );
400 
402  void ComputeHessian( const NeighborhoodType &it,
403  GlobalDataStruct *globalData );
404 
406  virtual void ComputeParameters() = 0;
407 
410  virtual void UpdateSharedDataParameters() = 0;
411 
412  bool m_UpdateC;
413 
416  static VectorType InitializeZeroVectorConstant();
417 
420 
421 private:
422  RegionBasedLevelSetFunction(const Self&); //purposely not implemented
423  void operator=(const Self&); //purposely not implemented
424 };
425 
426 } // end namespace itk
427 
428 #ifndef ITK_MANUAL_INSTANTIATION
430 #endif
431 
432 #endif

Generated at Sun Feb 3 2013 00:02:44 for Orfeo Toolbox with doxygen 1.8.1.1