00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __itkResampleImageFilter_h
00018 #define __itkResampleImageFilter_h
00019
00020
00021
00022
00023 #include "itkConfigure.h"
00024
00025 #ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS
00026 #include "itkOptResampleImageFilter.h"
00027 #else
00028
00029 #include "itkFixedArray.h"
00030 #include "itkTransform.h"
00031 #include "itkImageFunction.h"
00032 #include "itkImageRegionIterator.h"
00033 #include "itkImageToImageFilter.h"
00034 #include "itkInterpolateImageFunction.h"
00035 #include "itkSize.h"
00036
00037 namespace itk
00038 {
00039
00077 template <class TInputImage, class TOutputImage,
00078 class TInterpolatorPrecisionType=double>
00079 class ITK_EXPORT ResampleImageFilter:
00080 public ImageToImageFilter<TInputImage, TOutputImage>
00081 {
00082 public:
00084 typedef ResampleImageFilter Self;
00085 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
00086 typedef SmartPointer<Self> Pointer;
00087 typedef SmartPointer<const Self> ConstPointer;
00088
00089 typedef TInputImage InputImageType;
00090 typedef TOutputImage OutputImageType;
00091 typedef typename InputImageType::Pointer InputImagePointer;
00092 typedef typename InputImageType::ConstPointer InputImageConstPointer;
00093 typedef typename OutputImageType::Pointer OutputImagePointer;
00094 typedef typename InputImageType::RegionType InputImageRegionType;
00095
00097 itkNewMacro(Self);
00098
00100 itkTypeMacro(ResampleImageFilter, ImageToImageFilter);
00101
00103 itkStaticConstMacro(ImageDimension, unsigned int,
00104 TOutputImage::ImageDimension);
00105 itkStaticConstMacro(InputImageDimension, unsigned int,
00106 TInputImage::ImageDimension);
00108
00109
00111 typedef Transform<TInterpolatorPrecisionType,
00112 itkGetStaticConstMacro(ImageDimension),
00113 itkGetStaticConstMacro(ImageDimension)> TransformType;
00114 typedef typename TransformType::ConstPointer TransformPointerType;
00116
00118 typedef InterpolateImageFunction<InputImageType, TInterpolatorPrecisionType> InterpolatorType;
00119 typedef typename InterpolatorType::Pointer InterpolatorPointerType;
00120
00122 typedef Size<itkGetStaticConstMacro(ImageDimension)> SizeType;
00123
00125 typedef typename TOutputImage::IndexType IndexType;
00126
00128 typedef typename InterpolatorType::PointType PointType;
00129
00130
00132 typedef typename TOutputImage::PixelType PixelType;
00133 typedef typename TInputImage::PixelType InputPixelType;
00134
00136 typedef typename TOutputImage::RegionType OutputImageRegionType;
00137
00139 typedef typename TOutputImage::SpacingType SpacingType;
00140 typedef typename TOutputImage::PointType OriginPointType;
00141 typedef typename TOutputImage::DirectionType DirectionType;
00142
00150 itkSetConstObjectMacro( Transform, TransformType );
00151
00153 itkGetConstObjectMacro( Transform, TransformType );
00154
00161 itkSetObjectMacro( Interpolator, InterpolatorType );
00162
00164 itkGetConstObjectMacro( Interpolator, InterpolatorType );
00165
00167 itkSetMacro( Size, SizeType );
00168
00170 itkGetConstReferenceMacro( Size, SizeType );
00171
00174 itkSetMacro( DefaultPixelValue, PixelType );
00175
00177 itkGetConstReferenceMacro( DefaultPixelValue, PixelType );
00178
00180 itkSetMacro( OutputSpacing, SpacingType );
00181 virtual void SetOutputSpacing( const double* values );
00183
00185 itkGetConstReferenceMacro( OutputSpacing, SpacingType );
00186
00188 itkSetMacro( OutputOrigin, OriginPointType );
00189 virtual void SetOutputOrigin( const double* values);
00191
00193 itkGetConstReferenceMacro( OutputOrigin, OriginPointType );
00194
00196 itkSetMacro( OutputDirection, DirectionType );
00197 itkGetConstReferenceMacro( OutputDirection, DirectionType );
00199
00201 void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image )
00202 {
00203 this->SetOutputOrigin ( Image->GetOrigin() );
00204 this->SetOutputSpacing ( Image->GetSpacing() );
00205 this->SetOutputDirection ( Image->GetDirection() );
00206 this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00207 }
00209
00211 void SetOutputParametersFromConstImage ( typename OutputImageType::ConstPointer Image )
00212 {
00213 this->SetOutputOrigin ( Image->GetOrigin() );
00214 this->SetOutputSpacing ( Image->GetSpacing() );
00215 this->SetOutputDirection ( Image->GetDirection() );
00216 this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00217 }
00219
00222 itkSetMacro( OutputStartIndex, IndexType );
00223
00225 itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00226
00233 void SetReferenceImage ( const TOutputImage *image );
00234 const TOutputImage * GetReferenceImage( void ) const;
00236
00237 itkSetMacro( UseReferenceImage, bool );
00238 itkBooleanMacro( UseReferenceImage );
00239 itkGetMacro( UseReferenceImage, bool );
00240
00246 virtual void GenerateOutputInformation( void );
00247
00253 virtual void GenerateInputRequestedRegion( void );
00254
00257 virtual void BeforeThreadedGenerateData( void );
00258
00261 virtual void AfterThreadedGenerateData( void );
00262
00264 unsigned long GetMTime( void ) const;
00265
00266 #ifdef ITK_USE_CONCEPT_CHECKING
00267
00268 itkConceptMacro(OutputHasNumericTraitsCheck,
00269 (Concept::HasNumericTraits<PixelType>));
00270
00272 #endif
00273
00274 protected:
00275 ResampleImageFilter( void );
00276 ~ResampleImageFilter( void ) {};
00277
00278 void PrintSelf( std::ostream& os, Indent indent ) const;
00279
00288 void ThreadedGenerateData( const OutputImageRegionType& outputRegionForThread,
00289 int threadId );
00290
00293 void NonlinearThreadedGenerateData( const OutputImageRegionType& outputRegionForThread,
00294 int threadId );
00295
00299 void LinearThreadedGenerateData( const OutputImageRegionType&
00300 outputRegionForThread,
00301 int threadId );
00302
00303
00304 private:
00305 ResampleImageFilter( const Self& );
00306 void operator=( const Self& );
00307
00308 SizeType m_Size;
00309 TransformPointerType m_Transform;
00310 InterpolatorPointerType m_Interpolator;
00311
00312 PixelType m_DefaultPixelValue;
00313
00314
00315 SpacingType m_OutputSpacing;
00316 OriginPointType m_OutputOrigin;
00317 DirectionType m_OutputDirection;
00318 IndexType m_OutputStartIndex;
00319 bool m_UseReferenceImage;
00320
00321 };
00322
00323
00324 }
00325
00326 #ifndef ITK_MANUAL_INSTANTIATION
00327 #include "itkResampleImageFilter.txx"
00328 #endif
00329
00330 #endif
00331
00332 #endif
00333