Orfeo Toolbox  3.16
itkCurvatureFlowImageFilter.txx
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkCurvatureFlowImageFilter.txx,v $
5  Language: C++
6  Date: $Date: 2008-10-23 16:15:23 $
7  Version: $Revision: 1.33 $
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 __itkCurvatureFlowImageFilter_txx
18 #define __itkCurvatureFlowImageFilter_txx
19 
21 #include "itkExceptionObject.h"
22 
23 namespace itk
24 {
25 
29 template <class TInputImage, class TOutputImage>
32 {
33 
34  this->SetNumberOfIterations(0);
35  m_TimeStep = 0.05f;
36 
38  cffp = CurvatureFlowFunctionType::New();
39 
40  this->SetDifferenceFunction( static_cast<FiniteDifferenceFunctionType *>(
41  cffp.GetPointer() ) );
42 
43 }
44 
45 
49 template <class TInputImage, class TOutputImage>
50 void
52 ::PrintSelf(std::ostream& os, Indent indent) const
53 {
54  Superclass::PrintSelf(os, indent);
55  os << indent << "Time step: " << m_TimeStep;
56  os << std::endl;
57 }
58 
59 
63 template <class TInputImage, class TOutputImage>
64 void
67 {
68 
69  // update variables in the equation object
71  dynamic_cast<CurvatureFlowFunctionType *>
72  (this->GetDifferenceFunction().GetPointer());
73 
74  if ( !f )
75  {
76  itkExceptionMacro(<<"DifferenceFunction not of type CurvatureFlowFunction");
77  }
78 
79  f->SetTimeStep( m_TimeStep );
80 
81  // call superclass's version
82  this->Superclass::InitializeIteration();
83 
84  // progress feedback
85  if ( this->GetNumberOfIterations() != 0 )
86  {
87  this->UpdateProgress(((float)(this->GetElapsedIterations()))
88  /((float)(this->GetNumberOfIterations())));
89  }
90 
91 }
92 
93 
97 template <class TInputImage, class TOutputImage>
98 void
101 {
102  // call the superclass's implementation
103  Superclass::GenerateInputRequestedRegion();
104 
105  // get pointers to the input and output
106  typename Superclass::InputImagePointer inputPtr =
107  const_cast< InputImageType * >( this->GetInput() );
108  OutputImagePointer outputPtr = this->GetOutput();
109 
110  if ( !inputPtr || !outputPtr )
111  {
112  return;
113  }
114 
115  // set the input requested region to be the same as
116  // the output requested region
117  inputPtr->SetRequestedRegion(
118  outputPtr->GetRequestedRegion() );
119 
120 }
121 
122 
126 template <class TInputImage, class TOutputImage>
127 void
130  DataObject * ptr )
131 {
132 
133  // convert DataObject pointer to OutputImageType pointer
134  OutputImageType * outputPtr;
135  outputPtr = dynamic_cast<OutputImageType*>( ptr );
136 
137  // get input image pointer
138  typename Superclass::InputImagePointer inputPtr =
139  const_cast< InputImageType * >( this->GetInput() );
140  if ( !inputPtr || !outputPtr )
141  {
142  return;
143  }
144 
145  // Get the size of the neighborhood on which we are going to operate. This
146  // radius is supplied by the difference function we are using.
148  = this->GetDifferenceFunction()->GetRadius();
149 
150  for( unsigned int j = 0; j < ImageDimension; j++ )
151  {
152  radius[j] *= this->GetNumberOfIterations();
153  }
154 
159  typename OutputImageType::RegionType outputRequestedRegion =
160  outputPtr->GetRequestedRegion();
161 
162  outputRequestedRegion.PadByRadius( radius );
163  outputRequestedRegion.Crop( outputPtr->GetLargestPossibleRegion() );
164 
165  outputPtr->SetRequestedRegion( outputRequestedRegion );
166 }
167 
168 } // end namespace itk
169 
170 #endif

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