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 "itkImageFunction.h"
00025 #include "itkImageRegionIterator.h"
00026 #include "itkImageToImageFilter.h"
00027 #include "itkInterpolateImageFunction.h"
00028 #include "itkSize.h"
00029
00030 namespace itk
00031 {
00032
00070 template <class TInputImage, class TOutputImage, class TInterpolatorPrecisionType=double>
00071 class ITK_EXPORT ResampleImageFilter:
00072 public ImageToImageFilter<TInputImage, TOutputImage>
00073 {
00074 public:
00076 typedef ResampleImageFilter Self;
00077 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
00078 typedef SmartPointer<Self> Pointer;
00079 typedef SmartPointer<const Self> ConstPointer;
00080 typedef TInputImage InputImageType;
00081 typedef TOutputImage OutputImageType;
00082 typedef typename InputImageType::Pointer InputImagePointer;
00083 typedef typename InputImageType::ConstPointer InputImageConstPointer;
00084 typedef typename OutputImageType::Pointer OutputImagePointer;
00085 typedef typename InputImageType::RegionType InputImageRegionType;
00086
00088 itkNewMacro(Self);
00089
00091 itkTypeMacro(ResampleImageFilter, ImageToImageFilter);
00092
00094 itkStaticConstMacro(ImageDimension, unsigned int,
00095 TOutputImage::ImageDimension);
00096 itkStaticConstMacro(InputImageDimension, unsigned int,
00097 TInputImage::ImageDimension);
00098
00099
00105 typedef Transform<TInterpolatorPrecisionType, itkGetStaticConstMacro(ImageDimension), itkGetStaticConstMacro(ImageDimension)> TransformType;
00106 typedef typename TransformType::ConstPointer TransformPointerType;
00107
00111 typedef MatrixOffsetTransformBase<TInterpolatorPrecisionType, itkGetStaticConstMacro(ImageDimension), itkGetStaticConstMacro(ImageDimension)> LinearTransformType;
00112 typedef typename LinearTransformType::ConstPointer LinearTransformPointerType;
00113
00116 typedef IdentityTransform<TInterpolatorPrecisionType, itkGetStaticConstMacro(ImageDimension)> IdentityTransformType;
00117 typedef typename IdentityTransformType::ConstPointer IdentityTransformPointerType;
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 TInputImage::DirectionType DirectionType;
00144
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 itkGetMacro(DefaultPixelValue,PixelType);
00178
00180 itkSetMacro(OutputSpacing, SpacingType);
00181 virtual void SetOutputSpacing( const double* values);
00182
00184 itkGetConstReferenceMacro( OutputSpacing, SpacingType );
00185
00187 itkSetMacro(OutputOrigin, PointType);
00188 virtual void SetOutputOrigin( const double* values);
00189
00191 itkGetConstReferenceMacro( OutputOrigin, PointType );
00192
00194 itkSetMacro(OutputDirection, DirectionType);
00195 itkGetConstReferenceMacro(OutputDirection, DirectionType);
00196
00198 void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image ) {
00199 this->SetOutputOrigin ( Image->GetOrigin() );
00200 this->SetOutputSpacing ( Image->GetSpacing() );
00201 this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00202 }
00203
00206 itkSetMacro( OutputStartIndex, IndexType );
00207
00209 itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00210
00215 void SetReferenceImage (TOutputImage *image)
00216 {
00217 if (image != m_ReferenceImage)
00218 {
00219 m_ReferenceImage = image;
00220 this->ProcessObject::SetNthInput(1, image);
00221 this->Modified();
00222 }
00223 }
00224 itkGetObjectMacro(ReferenceImage, TOutputImage);
00225
00226 itkSetMacro(UseReferenceImage, bool);
00227 itkBooleanMacro(UseReferenceImage);
00228 itkGetMacro(UseReferenceImage, bool);
00229
00235 virtual void GenerateOutputInformation();
00236
00242 virtual void GenerateInputRequestedRegion();
00243
00246 virtual void BeforeThreadedGenerateData();
00247
00250 virtual void AfterThreadedGenerateData();
00251
00253 unsigned long GetMTime( void ) const;
00254
00255 protected:
00256 ResampleImageFilter();
00257 ~ResampleImageFilter() {};
00258 void PrintSelf(std::ostream& os, Indent indent) const;
00259
00268 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00269 int threadId );
00270
00273 void NonlinearThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00274 int threadId );
00275
00278 void LinearThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00279 int threadId );
00280
00281
00282 private:
00283 ResampleImageFilter(const Self&);
00284 void operator=(const Self&);
00285
00286 OutputImagePointer m_ReferenceImage;
00287
00288 SizeType m_Size;
00289 TransformPointerType m_Transform;
00290 InterpolatorPointerType m_Interpolator;
00291 PixelType m_DefaultPixelValue;
00292
00293 SpacingType m_OutputSpacing;
00294 PointType m_OutputOrigin;
00295 DirectionType m_OutputDirection;
00296 IndexType m_OutputStartIndex;
00297 bool m_UseReferenceImage;
00298
00299 };
00300
00301
00302 }
00303
00304 #ifndef ITK_MANUAL_INSTANTIATION
00305 #include "itkResampleImageFilter.txx"
00306 #endif
00307
00308 #endif