itkResampleImageFilter.h
Go to the documentation of this file.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->SetOutputStartIndex ( Image->GetLargestPossibleRegion().GetIndex() );
00207 this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00208 }
00210
00212 void SetOutputParametersFromConstImage ( typename OutputImageType::ConstPointer Image )
00213 {
00214 this->SetOutputOrigin ( Image->GetOrigin() );
00215 this->SetOutputSpacing ( Image->GetSpacing() );
00216 this->SetOutputDirection ( Image->GetDirection() );
00217 this->SetOutputStartIndex ( Image->GetLargestPossibleRegion().GetIndex() ); this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00218 }
00220
00223 itkSetMacro( OutputStartIndex, IndexType );
00224
00226 itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00227
00234 void SetReferenceImage ( const TOutputImage *image );
00235 const TOutputImage * GetReferenceImage( void ) const;
00237
00238 itkSetMacro( UseReferenceImage, bool );
00239 itkBooleanMacro( UseReferenceImage );
00240 itkGetMacro( UseReferenceImage, bool );
00241
00247 virtual void GenerateOutputInformation( void );
00248
00254 virtual void GenerateInputRequestedRegion( void );
00255
00258 virtual void BeforeThreadedGenerateData( void );
00259
00262 virtual void AfterThreadedGenerateData( void );
00263
00265 unsigned long GetMTime( void ) const;
00266
00267 #ifdef ITK_USE_CONCEPT_CHECKING
00268
00269 itkConceptMacro(OutputHasNumericTraitsCheck,
00270 (Concept::HasNumericTraits<PixelType>));
00271
00273 #endif
00274
00275 protected:
00276 ResampleImageFilter( void );
00277 ~ResampleImageFilter( void ) {};
00278
00279 void PrintSelf( std::ostream& os, Indent indent ) const;
00280
00289 void ThreadedGenerateData( const OutputImageRegionType& outputRegionForThread,
00290 int threadId );
00291
00294 void NonlinearThreadedGenerateData( const OutputImageRegionType& outputRegionForThread,
00295 int threadId );
00296
00300 void LinearThreadedGenerateData( const OutputImageRegionType&
00301 outputRegionForThread,
00302 int threadId );
00303
00304
00305 private:
00306 ResampleImageFilter( const Self& );
00307 void operator=( const Self& );
00308
00309 SizeType m_Size;
00310 TransformPointerType m_Transform;
00311 InterpolatorPointerType m_Interpolator;
00312
00313 PixelType m_DefaultPixelValue;
00314
00315
00316 SpacingType m_OutputSpacing;
00317 OriginPointType m_OutputOrigin;
00318 DirectionType m_OutputDirection;
00319 IndexType m_OutputStartIndex;
00320 bool m_UseReferenceImage;
00321
00322 };
00323
00324
00325 }
00326
00327 #ifndef ITK_MANUAL_INSTANTIATION
00328 #include "itkResampleImageFilter.txx"
00329 #endif
00330
00331 #endif
00332
00333 #endif
00334