Orfeo Toolbox  3.16
itkCurvesLevelSetFunction.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkCurvesLevelSetFunction.txx,v $
5  Language: C++
6  Date: $Date: 2008-10-23 16:15:23 $
7  Version: $Revision: 1.4 $
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 __itkCurvesLevelSetFunction_txx
18 #define __itkCurvesLevelSetFunction_txx
19 
21 #include "itkImageRegionIterator.h"
23 #include "itkGradientImageFilter.h"
25 
26 namespace itk {
27 
28 template< class TImageType, class TFeatureImageType>
29 void
32 {
33 
34  Superclass::Initialize(r);
35 
36  this->SetAdvectionWeight( NumericTraits<ScalarValueType>::One );
37  this->SetPropagationWeight( NumericTraits<ScalarValueType>::One );
38  this->SetCurvatureWeight( NumericTraits<ScalarValueType>::One );
39 
40 }
41 
42 template <class TImageType, class TFeatureImageType>
45 {
46  /* copy the feature image into the speed image */
48  fit(this->GetFeatureImage(), this->GetFeatureImage()->GetRequestedRegion());
50  sit(this->GetSpeedImage(), this->GetFeatureImage()->GetRequestedRegion());
51 
52  for ( fit.GoToBegin(), sit.GoToBegin(); ! fit.IsAtEnd(); ++sit, ++fit)
53  {
54  sit.Set( static_cast<ScalarValueType>( fit.Get() ) );
55  }
56 }
57 
58 
59 template <class TImageType, class TFeatureImageType>
62 {
63  /* compute the gradient of the feature image. */
64 
65  typename VectorImageType::Pointer gradientImage;
66 
67  if (m_DerivativeSigma != NumericTraits<float>::Zero)
68  {
70  DerivativeFilterType;
71 
72  typename DerivativeFilterType::Pointer derivative = DerivativeFilterType::New();
73  derivative->SetInput( this->GetFeatureImage() );
74  derivative->SetSigma( m_DerivativeSigma );
75  derivative->Update();
76 
77  gradientImage = derivative->GetOutput();
78  }
79  else
80  {
81  typedef GradientImageFilter<FeatureImageType> DerivativeFilterType;
82 
83  typename DerivativeFilterType::Pointer derivative = DerivativeFilterType::New();
84  derivative->SetInput( this->GetFeatureImage() );
85  derivative->SetUseImageSpacingOn();
86  derivative->Update();
87 
88  typedef typename DerivativeFilterType::OutputImageType DerivativeOutputImageType;
90 
91  typename GradientCasterType::Pointer caster = GradientCasterType::New();
92  caster->SetInput(derivative->GetOutput());
93  caster->Update();
94 
95  gradientImage = caster->GetOutput();
96  }
97 
98  /* copy negative gradient into the advection image. */
100  dit( gradientImage, this->GetFeatureImage()->GetRequestedRegion() );
102  ait( this->GetAdvectionImage(), this->GetFeatureImage()->GetRequestedRegion() );
103 
104  for( dit.GoToBegin(), ait.GoToBegin(); !dit.IsAtEnd(); ++dit, ++ait )
105  {
106  typename VectorImageType::PixelType v = dit.Get();
107  for ( unsigned int j = 0; j < ImageDimension; j++ )
108  {
109  v[j] *= -1.0L;
110  }
111  ait.Set( v);
112  }
113 }
114 
115 } // end namespace itk
116 
117 
118 #endif

Generated at Sat Feb 2 2013 23:34:19 for Orfeo Toolbox with doxygen 1.8.1.1