19 #ifndef __itkDeformationFieldSource_txx
20 #define __itkDeformationFieldSource_txx
33 template <
class TOutputImage>
37 m_OutputSpacing.Fill(1.0);
38 m_OutputOrigin.Fill(0.0);
39 m_OutputDirection.SetIdentity();
43 itkGetStaticConstMacro( ImageDimension ) > DefaultTransformType;
45 m_KernelTransform = DefaultTransformType::New();
55 template <
class TOutputImage>
60 Superclass::PrintSelf(os,indent);
62 os << indent <<
"OutputRegion: " << m_OutputRegion << std::endl;
63 os << indent <<
"OutputSpacing: " << m_OutputSpacing << std::endl;
64 os << indent <<
"OutputOrigin: " << m_OutputOrigin << std::endl;
65 os << indent <<
"OutputDirection: " << m_OutputDirection << std::endl;
66 os << indent <<
"KernelTransform: " << m_KernelTransform.GetPointer() << std::endl;
67 os << indent <<
"Source Landmarks: " << m_SourceLandmarks.GetPointer() << std::endl;
68 os << indent <<
"Target Landmarks: " << m_TargetLandmarks.GetPointer() << std::endl;
76 template <
class TOutputImage>
80 const double* spacing)
83 this->SetOutputSpacing( s );
89 template <
class TOutputImage>
96 this->SetOutputOrigin( p );
103 template <
class TOutputImage>
116 m_SourceLandmarks.GetPointer() );
120 m_TargetLandmarks.GetPointer() );
122 m_KernelTransform->GetTargetLandmarks()->SetPoints( targets );
123 m_KernelTransform->GetSourceLandmarks()->SetPoints( sources );
125 itkDebugMacro( <<
"Before ComputeWMatrix() ");
127 m_KernelTransform->ComputeWMatrix();
129 itkDebugMacro( <<
"After ComputeWMatrix() ");
136 template <
class TOutputImage>
144 this->PrepareKernelBaseSpline();
146 itkDebugMacro(<<
"Actually executing");
151 outputPtr->SetBufferedRegion( outputPtr->GetRequestedRegion() );
152 outputPtr->Allocate();
156 TOutputImage> OutputIterator;
160 OutputIterator outIt( outputPtr, region );
169 InputPointType outputPoint;
177 while ( !outIt.IsAtEnd() )
180 outputIndex = outIt.GetIndex();
181 outputPtr->TransformIndexToPhysicalPoint( outputIndex, outputPoint );
185 OutputPointType interpolatedDeformation =
186 m_KernelTransform->TransformPoint( outputPoint );
189 for(
unsigned int i=0; i < ImageDimension; i++)
191 displacement[i] = interpolatedDeformation[i] - outputPoint[i];
194 outIt.Set( displacement );
205 template <
class TOutputImage>
211 Superclass::GenerateOutputInformation();
221 outputPtr->SetLargestPossibleRegion( m_OutputRegion );
224 outputPtr->SetSpacing( m_OutputSpacing );
225 outputPtr->SetOrigin( m_OutputOrigin );
226 outputPtr->SetDirection( m_OutputDirection );
234 template <
class TOutputImage>
241 if( m_KernelTransform )
243 if( latestTime < m_KernelTransform->GetMTime() )
245 latestTime = m_KernelTransform->GetMTime();
249 if( m_SourceLandmarks )
251 if( latestTime < m_SourceLandmarks->GetMTime() )
253 latestTime = m_SourceLandmarks->GetMTime();
258 if( m_TargetLandmarks )
260 if( latestTime < m_TargetLandmarks->GetMTime() )
262 latestTime = m_TargetLandmarks->GetMTime();