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
00113 typedef Transform<TInterpolatorPrecisionType,
00114 itkGetStaticConstMacro(ImageDimension),
00115 itkGetStaticConstMacro(ImageDimension)> TransformType;
00116 typedef typename TransformType::ConstPointer TransformPointerType;
00118
00120 typedef InterpolateImageFunction<InputImageType, TInterpolatorPrecisionType> InterpolatorType;
00121 typedef typename InterpolatorType::Pointer InterpolatorPointerType;
00122
00124 typedef Size<itkGetStaticConstMacro(ImageDimension)> SizeType;
00125
00127 typedef typename TOutputImage::IndexType IndexType;
00128
00130 typedef typename InterpolatorType::PointType PointType;
00131
00132
00134 typedef typename TOutputImage::PixelType PixelType;
00135 typedef typename TInputImage::PixelType InputPixelType;
00136
00138 typedef typename TOutputImage::RegionType OutputImageRegionType;
00139
00141 typedef typename TOutputImage::SpacingType SpacingType;
00142 typedef typename TOutputImage::PointType OriginPointType;
00143 typedef typename TOutputImage::DirectionType DirectionType;
00144
00152 itkSetConstObjectMacro( Transform, TransformType );
00153
00155 itkGetConstObjectMacro( Transform, TransformType );
00156
00163 itkSetObjectMacro( Interpolator, InterpolatorType );
00164
00166 itkGetConstObjectMacro( Interpolator, InterpolatorType );
00167
00169 itkSetMacro( Size, SizeType );
00170
00172 itkGetConstReferenceMacro( Size, SizeType );
00173
00176 itkSetMacro( DefaultPixelValue, PixelType );
00177
00179 itkGetMacro( DefaultPixelValue, PixelType );
00180
00182 itkSetMacro( OutputSpacing, SpacingType );
00183 virtual void SetOutputSpacing( const double* values );
00185
00187 itkGetConstReferenceMacro( OutputSpacing, SpacingType );
00188
00190 itkSetMacro( OutputOrigin, OriginPointType );
00191 virtual void SetOutputOrigin( const double* values);
00193
00195 itkGetConstReferenceMacro( OutputOrigin, OriginPointType );
00196
00198 itkSetMacro( OutputDirection, DirectionType );
00199 itkGetConstReferenceMacro( OutputDirection, DirectionType );
00201
00203 void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image )
00204 {
00205 this->SetOutputOrigin ( Image->GetOrigin() );
00206 this->SetOutputSpacing ( Image->GetSpacing() );
00207 this->SetOutputDirection ( Image->GetDirection() );
00208 this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00209 }
00211
00214 itkSetMacro( OutputStartIndex, IndexType );
00215
00217 itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00218
00225 void SetReferenceImage ( const TOutputImage *image );
00226 const TOutputImage * GetReferenceImage( void ) const;
00228
00229 itkSetMacro( UseReferenceImage, bool );
00230 itkBooleanMacro( UseReferenceImage );
00231 itkGetMacro( UseReferenceImage, bool );
00232
00238 virtual void GenerateOutputInformation( void );
00239
00245 virtual void GenerateInputRequestedRegion( void );
00246
00249 virtual void BeforeThreadedGenerateData( void );
00250
00253 virtual void AfterThreadedGenerateData( void );
00254
00256 unsigned long GetMTime( void ) const;
00257
00258 #ifdef ITK_USE_CONCEPT_CHECKING
00259
00260 itkConceptMacro(OutputHasNumericTraitsCheck,
00261 (Concept::HasNumericTraits<PixelType>));
00262
00264 #endif
00265
00266 protected:
00267 ResampleImageFilter( void );
00268 ~ResampleImageFilter( void ) {};
00269
00270 void PrintSelf( std::ostream& os, Indent indent ) const;
00271
00280 void ThreadedGenerateData( const OutputImageRegionType& outputRegionForThread,
00281 int threadId );
00282
00285 void NonlinearThreadedGenerateData( const OutputImageRegionType& outputRegionForThread,
00286 int threadId );
00287
00291 void LinearThreadedGenerateData( const OutputImageRegionType&
00292 outputRegionForThread,
00293 int threadId );
00294
00295
00296 private:
00297 ResampleImageFilter( const Self& );
00298 void operator=( const Self& );
00299
00300 SizeType m_Size;
00301 TransformPointerType m_Transform;
00302 InterpolatorPointerType m_Interpolator;
00303
00304 PixelType m_DefaultPixelValue;
00305
00306
00307 SpacingType m_OutputSpacing;
00308 OriginPointType m_OutputOrigin;
00309 DirectionType m_OutputDirection;
00310 IndexType m_OutputStartIndex;
00311 bool m_UseReferenceImage;
00312
00313 };
00314
00315
00316 }
00317
00318 #ifndef ITK_MANUAL_INSTANTIATION
00319 #include "itkResampleImageFilter.txx"
00320 #endif
00321
00322 #endif
00323
00324 #endif
00325
00326