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 "itkImageFunction.h"
00023 #include "itkImageRegionIterator.h"
00024 #include "itkImageToImageFilter.h"
00025 #include "itkInterpolateImageFunction.h"
00026 #include "itkSize.h"
00027
00028 namespace itk
00029 {
00030
00068 template <class TInputImage, class TOutputImage, class TInterpolatorPrecisionType=double>
00069 class ITK_EXPORT ResampleImageFilter:
00070 public ImageToImageFilter<TInputImage, TOutputImage>
00071 {
00072 public:
00074 typedef ResampleImageFilter Self;
00075 typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
00076 typedef SmartPointer<Self> Pointer;
00077 typedef SmartPointer<const Self> ConstPointer;
00078 typedef TInputImage InputImageType;
00079 typedef TOutputImage OutputImageType;
00080 typedef typename InputImageType::Pointer InputImagePointer;
00081 typedef typename OutputImageType::Pointer OutputImagePointer;
00082 typedef typename InputImageType::RegionType InputImageRegionType;
00083
00085 itkNewMacro(Self);
00086
00088 itkTypeMacro(ResampleImageFilter, ImageToImageFilter);
00089
00091 itkStaticConstMacro(ImageDimension, unsigned int,
00092 TOutputImage::ImageDimension);
00093
00099 typedef Transform<TInterpolatorPrecisionType, itkGetStaticConstMacro(ImageDimension), itkGetStaticConstMacro(ImageDimension)> TransformType;
00100 typedef typename TransformType::ConstPointer TransformPointerType;
00101
00103 typedef InterpolateImageFunction<InputImageType, TInterpolatorPrecisionType> InterpolatorType;
00104 typedef typename InterpolatorType::Pointer InterpolatorPointerType;
00105
00107 typedef Size<itkGetStaticConstMacro(ImageDimension)> SizeType;
00108
00110 typedef typename TOutputImage::IndexType IndexType;
00111
00113 typedef typename InterpolatorType::PointType PointType;
00114
00115
00117 typedef typename TOutputImage::PixelType PixelType;
00118
00120 typedef typename TOutputImage::RegionType OutputImageRegionType;
00121
00123 typedef typename TOutputImage::SpacingType SpacingType;
00124 typedef typename TOutputImage::PointType OriginPointType;
00125 typedef typename TInputImage::DirectionType DirectionType;
00126
00132 itkSetConstObjectMacro( Transform, TransformType );
00133
00135 itkGetConstObjectMacro( Transform, TransformType );
00136
00143 itkSetObjectMacro( Interpolator, InterpolatorType );
00144
00146 itkGetConstObjectMacro( Interpolator, InterpolatorType );
00147
00149 itkSetMacro( Size, SizeType );
00150
00152 itkGetConstReferenceMacro( Size, SizeType );
00153
00156 itkSetMacro(DefaultPixelValue,PixelType);
00157
00159 itkGetMacro(DefaultPixelValue,PixelType);
00160
00162 itkSetMacro(OutputSpacing, SpacingType);
00163 virtual void SetOutputSpacing( const double* values);
00164
00166 itkGetConstReferenceMacro( OutputSpacing, SpacingType );
00167
00169 itkSetMacro(OutputOrigin, PointType);
00170 virtual void SetOutputOrigin( const double* values);
00171
00173 itkGetConstReferenceMacro( OutputOrigin, PointType );
00174
00176 itkSetMacro(OutputDirection, DirectionType);
00177 itkGetConstReferenceMacro(OutputDirection, DirectionType);
00178
00180 void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image ) {
00181 this->SetOutputOrigin ( Image->GetOrigin() );
00182 this->SetOutputSpacing ( Image->GetSpacing() );
00183 this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00184 }
00185
00188 itkSetMacro( OutputStartIndex, IndexType );
00189
00191 itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00192
00197 void SetReferenceImage (TOutputImage *image)
00198 {
00199 if (image != m_ReferenceImage)
00200 {
00201 m_ReferenceImage = image;
00202 this->ProcessObject::SetNthInput(1, image);
00203 this->Modified();
00204 }
00205 }
00206 itkGetObjectMacro(ReferenceImage, TOutputImage);
00207
00208 itkSetMacro(UseReferenceImage, bool);
00209 itkBooleanMacro(UseReferenceImage);
00210 itkGetMacro(UseReferenceImage, bool);
00211
00217 virtual void GenerateOutputInformation();
00218
00224 virtual void GenerateInputRequestedRegion();
00225
00228 virtual void BeforeThreadedGenerateData();
00229
00232 virtual void AfterThreadedGenerateData();
00233
00235 unsigned long GetMTime( void ) const;
00236
00237 protected:
00238 ResampleImageFilter();
00239 ~ResampleImageFilter() {};
00240 void PrintSelf(std::ostream& os, Indent indent) const;
00241
00250 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00251 int threadId );
00252
00253 private:
00254 ResampleImageFilter(const Self&);
00255 void operator=(const Self&);
00256
00257 OutputImagePointer m_ReferenceImage;
00258
00259 SizeType m_Size;
00260 TransformPointerType m_Transform;
00261 InterpolatorPointerType m_Interpolator;
00262 PixelType m_DefaultPixelValue;
00263
00264 SpacingType m_OutputSpacing;
00265 PointType m_OutputOrigin;
00266 DirectionType m_OutputDirection;
00267 IndexType m_OutputStartIndex;
00268 bool m_UseReferenceImage;
00269
00270 };
00271
00272
00273 }
00274
00275 #ifndef ITK_MANUAL_INSTANTIATION
00276 #include "itkResampleImageFilter.txx"
00277 #endif
00278
00279 #endif