Orfeo Toolbox  3.16
itkShapePriorSegmentationLevelSetFunction.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkShapePriorSegmentationLevelSetFunction.txx,v $
5  Language: C++
6  Date: $Date: 2009-01-27 19:30:16 $
7  Version: $Revision: 1.9 $
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 #ifndef __itkShapePriorSegmentationLevelSetFunction_txx
18 #define __itkShapePriorSegmentationLevelSetFunction_txx
19 
21 
22 
23 namespace itk {
24 
28 template <class TImageType, class TFeatureImageType>
31 {
32  m_ShapeFunction = NULL;
33  m_ShapePriorWeight = NumericTraits<ScalarValueType>::Zero;
34 }
35 
39 template <class TImageType, class TFeatureImageType>
40 void
42 ::PrintSelf( std::ostream& os, Indent indent) const
43 {
44  Superclass::PrintSelf( os, indent );
45  os << indent << "ShapeFunction: " << m_ShapeFunction.GetPointer() << std::endl;
46  os << indent << "ShapePriorWeight: " << m_ShapePriorWeight << std::endl;
47 }
48 
52 template <class TImageType, class TFeatureImageType>
54 ::PixelType
57 const NeighborhoodType &neighborhood,
58 void *gd,
59 const FloatOffsetType& offset )
60 {
61  // Compute the generic level set update using superclass
62  PixelType value = this->Superclass::ComputeUpdate( neighborhood, gd, offset );
63 
64  // Add the shape prior term
65  if ( m_ShapeFunction && m_ShapePriorWeight != NumericTraits<ScalarValueType>::Zero )
66  {
67  IndexType idx = neighborhood.GetIndex();
69  for( unsigned int i = 0; i < ImageDimension; ++i )
70  {
71  cdx[i] = static_cast<double>( idx[i] ) - offset[i];
72  }
73  typename ShapeFunctionType::PointType point;
74  this->GetFeatureImage()->TransformContinuousIndexToPhysicalPoint( cdx, point );
75 
76  ScalarValueType shape_term = m_ShapePriorWeight *
77  ( m_ShapeFunction->Evaluate( point ) - neighborhood.GetCenterPixel() );
78 
79  value += shape_term;
80 
81  // collect max change to be used for calculating the time step
83  globalData->m_MaxShapePriorChange
84  = vnl_math_max( globalData->m_MaxShapePriorChange, vnl_math_abs( shape_term ) );
85 
86  }
87 
88  return value;
89 
90 };
91 
95 template <class TImageType, class TFeatureImageType>
97 ::TimeStepType
99 ::ComputeGlobalTimeStep( void * gd ) const
100 {
101  TimeStepType dt;
102 
104 
106 
107  if (vnl_math_abs(d->m_MaxCurvatureChange) > 0.0)
108  {
109  if (d->m_MaxAdvectionChange > 0.0)
110  {
111  dt = vnl_math_min((this->m_WaveDT / d->m_MaxAdvectionChange),
112  ( this->m_DT / d->m_MaxCurvatureChange ));
113  }
114  else
115  {
116  dt = this->m_DT / d->m_MaxCurvatureChange;
117  }
118  }
119  else
120  {
121  if (d->m_MaxAdvectionChange > 0.0)
122  {
123  dt = this->m_WaveDT / d->m_MaxAdvectionChange;
124  }
125  else
126  {
127  dt = 0.0;
128  }
129  }
130 
131  double maxScaleCoefficient = 0.0;
132  for (unsigned int i=0; i<ImageDimension; i++)
133  {
134  maxScaleCoefficient = vnl_math_max(this->m_ScaleCoefficients[i],maxScaleCoefficient);
135  }
136  dt /= maxScaleCoefficient;
137 
138  // reset the values
139  d->m_MaxAdvectionChange = 0;
141  d->m_MaxCurvatureChange = 0;
142  d->m_MaxShapePriorChange = 0;
143 
144  return dt;
145 
146 }
147 
148 
149 } // end namespace itk
150 
151 
152 #endif

Generated at Sun Feb 3 2013 00:06:19 for Orfeo Toolbox with doxygen 1.8.1.1