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 #include "itkFixedArray.h"
00021 #include "itkTransform.h"
00022 #include "itkMatrixOffsetTransformBase.h"
00023 #include "itkIdentityTransform.h"
00024 #include "itkTranslationTransform.h"
00025 #include "itkImageFunction.h"
00026 #include "itkImageRegionIterator.h"
00027 #include "itkImageToImageFilter.h"
00028 #include "itkInterpolateImageFunction.h"
00029 #include "itkSize.h"
00030
00031 namespace itk
00032 {
00033
00071 template <class TInputImage, class TOutputImage, class TInterpolatorPrecisionType=double>
00072 class ITK_EXPORT ResampleImageFilter:
00073 public ImageToImageFilter<TInputImage, TOutputImage>
00074 {
00075 public:
00077 typedef ResampleImageFilter Self;
00078 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
00079 typedef SmartPointer<Self> Pointer;
00080 typedef SmartPointer<const Self> ConstPointer;
00081 typedef TInputImage InputImageType;
00082 typedef TOutputImage OutputImageType;
00083 typedef typename InputImageType::Pointer InputImagePointer;
00084 typedef typename InputImageType::ConstPointer InputImageConstPointer;
00085 typedef typename OutputImageType::Pointer OutputImagePointer;
00086 typedef typename InputImageType::RegionType InputImageRegionType;
00087
00089 itkNewMacro(Self);
00090
00092 itkTypeMacro(ResampleImageFilter, ImageToImageFilter);
00093
00095 itkStaticConstMacro(ImageDimension, unsigned int,
00096 TOutputImage::ImageDimension);
00097 itkStaticConstMacro(InputImageDimension, unsigned int,
00098 TInputImage::ImageDimension);
00100
00101
00107 typedef Transform<TInterpolatorPrecisionType, itkGetStaticConstMacro(ImageDimension), itkGetStaticConstMacro(ImageDimension)> TransformType;
00108 typedef typename TransformType::ConstPointer TransformPointerType;
00109
00113 typedef MatrixOffsetTransformBase<TInterpolatorPrecisionType, itkGetStaticConstMacro(ImageDimension), itkGetStaticConstMacro(ImageDimension)> LinearTransformType;
00114 typedef typename LinearTransformType::ConstPointer LinearTransformPointerType;
00115
00118 typedef IdentityTransform<TInterpolatorPrecisionType, itkGetStaticConstMacro(ImageDimension)> IdentityTransformType;
00119 typedef typename IdentityTransformType::ConstPointer IdentityTransformPointerType;
00120
00123 typedef TranslationTransform<TInterpolatorPrecisionType, itkGetStaticConstMacro(ImageDimension)> TranslationTransformType;
00124 typedef typename TranslationTransformType::ConstPointer TranslationTransformPointerType;
00125
00127 typedef InterpolateImageFunction<InputImageType, TInterpolatorPrecisionType> InterpolatorType;
00128 typedef typename InterpolatorType::Pointer InterpolatorPointerType;
00129
00131 typedef Size<itkGetStaticConstMacro(ImageDimension)> SizeType;
00132
00134 typedef typename TOutputImage::IndexType IndexType;
00135
00137 typedef typename InterpolatorType::PointType PointType;
00138
00139
00141 typedef typename TOutputImage::PixelType PixelType;
00142 typedef typename TInputImage::PixelType InputPixelType;
00143
00145 typedef typename TOutputImage::RegionType OutputImageRegionType;
00146
00148 typedef typename TOutputImage::SpacingType SpacingType;
00149 typedef typename TOutputImage::PointType OriginPointType;
00150 typedef typename TOutputImage::DirectionType DirectionType;
00151
00157 itkSetConstObjectMacro( Transform, TransformType );
00158
00160 itkGetConstObjectMacro( Transform, TransformType );
00161
00168 itkSetObjectMacro( Interpolator, InterpolatorType );
00169
00171 itkGetConstObjectMacro( Interpolator, InterpolatorType );
00172
00174 itkSetMacro( Size, SizeType );
00175
00177 itkGetConstReferenceMacro( Size, SizeType );
00178
00181 itkSetMacro(DefaultPixelValue,PixelType);
00182
00184 itkGetMacro(DefaultPixelValue,PixelType);
00185
00187 itkSetMacro(OutputSpacing, SpacingType);
00188 virtual void SetOutputSpacing( const double* values);
00190
00192 itkGetConstReferenceMacro( OutputSpacing, SpacingType );
00193
00195 itkSetMacro(OutputOrigin, PointType);
00196 virtual void SetOutputOrigin( const double* values);
00198
00200 itkGetConstReferenceMacro( OutputOrigin, PointType );
00201
00203 itkSetMacro(OutputDirection, DirectionType);
00204 itkGetConstReferenceMacro(OutputDirection, DirectionType);
00206
00208 void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image ) {
00209 this->SetOutputOrigin ( Image->GetOrigin() );
00210 this->SetOutputSpacing ( Image->GetSpacing() );
00211 this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00212 }
00214
00217 itkSetMacro( OutputStartIndex, IndexType );
00218
00220 itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00221
00226 void SetReferenceImage (TOutputImage *image)
00227 {
00228 if (image != m_ReferenceImage)
00229 {
00230 m_ReferenceImage = image;
00231 this->ProcessObject::SetNthInput(1, image);
00232 this->Modified();
00233 }
00234 }
00235 itkGetObjectMacro(ReferenceImage, TOutputImage);
00237
00238 itkSetMacro(UseReferenceImage, bool);
00239 itkBooleanMacro(UseReferenceImage);
00240 itkGetMacro(UseReferenceImage, bool);
00241
00247 virtual void GenerateOutputInformation();
00248
00254 virtual void GenerateInputRequestedRegion();
00255
00258 virtual void BeforeThreadedGenerateData();
00259
00262 virtual void AfterThreadedGenerateData();
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();
00277 ~ResampleImageFilter() {};
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
00298 void LinearThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00299 int threadId );
00300
00301
00302 private:
00303 ResampleImageFilter(const Self&);
00304 void operator=(const Self&);
00305
00306 OutputImagePointer m_ReferenceImage;
00307
00308 SizeType m_Size;
00309 TransformPointerType m_Transform;
00310 InterpolatorPointerType m_Interpolator;
00311 PixelType m_DefaultPixelValue;
00312
00313 SpacingType m_OutputSpacing;
00314 OriginPointType m_OutputOrigin;
00315 DirectionType m_OutputDirection;
00316 IndexType m_OutputStartIndex;
00317 bool m_UseReferenceImage;
00318
00319 };
00320
00321
00322 }
00323
00324 #ifndef ITK_MANUAL_INSTANTIATION
00325 #include "itkResampleImageFilter.txx"
00326 #endif
00327
00328 #endif
00329