17 #ifndef __itkInterpolateImageFilter_txx
18 #define __itkInterpolateImageFilter_txx
33 template <
class TInputImage,
class TOutputImage>
39 this->SetNumberOfRequiredInputs( 2 );
43 LinearInterpolatorType;
44 typename LinearInterpolatorType::Pointer interpolator =
45 LinearInterpolatorType::New();
47 m_Interpolator =
static_cast<InterpolatorType *
>( interpolator.GetPointer() );
52 m_IntermediateImage =
NULL;
60 template <
class TInputImage,
class TOutputImage>
67 const_cast< InputImageType * >( image ) );
75 template <
class TInputImage,
class TOutputImage>
80 if (this->GetNumberOfInputs() < 2)
85 return static_cast<const TInputImage *
>
93 template <
class TInputImage,
class TOutputImage>
99 this->Superclass::PrintSelf(os,indent);
101 os << indent <<
"Interpolator: " << m_Interpolator.GetPointer() << std::endl;
102 os << indent <<
"Distance: " << m_Distance << std::endl;
111 template <
class TInputImage,
class TOutputImage>
117 if( !m_Interpolator )
119 itkExceptionMacro(<<
"Interpolator not set");
124 typedef typename TOutputImage::RegionType ImageRegionType;
126 ImageRegionType outputRegion = this->GetOutput()->GetRequestedRegion();
128 IntermediateImageRegionType intermediateRegion;
132 RegionCopierType regionCopier;
133 regionCopier( intermediateRegion, outputRegion );
135 intermediateRegion.SetIndex( ImageDimension, 0 );
136 intermediateRegion.SetSize( ImageDimension, 2 );
138 m_IntermediateImage = IntermediateImageType::New();
139 m_IntermediateImage->SetRegions( intermediateRegion );
140 m_IntermediateImage->Allocate();
143 intermediateRegion.SetIndex( ImageDimension, 0 );
144 intermediateRegion.SetSize( ImageDimension, 1 );
148 intermediateRegion );
152 outIter.
Set( inIter.
Get() );
158 intermediateRegion.
SetIndex( ImageDimension, 1 );
159 intermediateRegion.SetSize( ImageDimension, 1 );
163 intermediateRegion );
167 outIter.Set( inIter.
Get() );
174 m_Interpolator->SetInputImage( m_IntermediateImage );
182 template <
class TInputImage,
class TOutputImage>
189 m_IntermediateImage =
NULL;
196 template <
class TInputImage,
class TOutputImage>
210 OutputIterator outIt(outputPtr, outputRegionForThread);
212 typedef typename TOutputImage::PixelType OutputPixelType;
213 typedef typename TOutputImage::IndexType IndexType;
216 IndexType outputIndex;
217 ContinuousIndexType intermediateIndex;
220 ProgressReporter progress(
this, threadId, outputRegionForThread.GetNumberOfPixels());
223 while ( !outIt.IsAtEnd() )
226 outputIndex = outIt.GetIndex();
227 for (
unsigned int j = 0; j< ImageDimension; ++j)
229 intermediateIndex[j] = (double) outputIndex[j];
231 intermediateIndex[ImageDimension] = m_Distance;
234 if( m_Interpolator->IsInsideBuffer(intermediateIndex) )
236 outIt.Set( static_cast<OutputPixelType>(
237 m_Interpolator->EvaluateAtContinuousIndex( intermediateIndex)));
242 itkExceptionMacro( <<
"Index not within the intermediate buffer" );
246 progress.CompletedPixel();