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
00079 typedef TInputImage InputImageType;
00080 typedef TOutputImage OutputImageType;
00081 typedef typename InputImageType::Pointer InputImagePointer;
00082 typedef typename InputImageType::ConstPointer InputImageConstPointer;
00083 typedef typename OutputImageType::Pointer OutputImagePointer;
00084 typedef typename InputImageType::RegionType InputImageRegionType;
00085
00087 itkNewMacro(Self);
00088
00090 itkTypeMacro(ResampleImageFilter, ImageToImageFilter);
00091
00093 itkStaticConstMacro(ImageDimension, unsigned int,
00094 TOutputImage::ImageDimension);
00095 itkStaticConstMacro(InputImageDimension, unsigned int,
00096 TInputImage::ImageDimension);
00098
00099
00103 typedef Transform<TInterpolatorPrecisionType,
00104 itkGetStaticConstMacro(ImageDimension),
00105 itkGetStaticConstMacro(ImageDimension)> TransformType;
00106 typedef typename TransformType::ConstPointer TransformPointerType;
00108
00110 typedef InterpolateImageFunction<InputImageType, TInterpolatorPrecisionType> InterpolatorType;
00111 typedef typename InterpolatorType::Pointer InterpolatorPointerType;
00112
00114 typedef Size<itkGetStaticConstMacro(ImageDimension)> SizeType;
00115
00117 typedef typename TOutputImage::IndexType IndexType;
00118
00120 typedef typename InterpolatorType::PointType PointType;
00121
00122
00124 typedef typename TOutputImage::PixelType PixelType;
00125 typedef typename TInputImage::PixelType InputPixelType;
00126
00128 typedef typename TOutputImage::RegionType OutputImageRegionType;
00129
00131 typedef typename TOutputImage::SpacingType SpacingType;
00132 typedef typename TOutputImage::PointType OriginPointType;
00133 typedef typename TOutputImage::DirectionType DirectionType;
00134
00142 itkSetConstObjectMacro( Transform, TransformType );
00143
00145 itkGetConstObjectMacro( Transform, TransformType );
00146
00153 itkSetObjectMacro( Interpolator, InterpolatorType );
00154
00156 itkGetConstObjectMacro( Interpolator, InterpolatorType );
00157
00159 itkSetMacro( Size, SizeType );
00160
00162 itkGetConstReferenceMacro( Size, SizeType );
00163
00166 itkSetMacro(DefaultPixelValue,PixelType);
00167
00169 itkGetMacro(DefaultPixelValue,PixelType);
00170
00172 itkSetMacro(OutputSpacing, SpacingType);
00173 virtual void SetOutputSpacing( const double* values);
00175
00177 itkGetConstReferenceMacro( OutputSpacing, SpacingType );
00178
00180 itkSetMacro(OutputOrigin, OriginPointType);
00181 virtual void SetOutputOrigin( const double* values);
00183
00185 itkGetConstReferenceMacro( OutputOrigin, OriginPointType );
00186
00188 itkSetMacro(OutputDirection, DirectionType);
00189 itkGetConstReferenceMacro(OutputDirection, DirectionType);
00191
00193 void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image )
00194 {
00195 this->SetOutputOrigin ( Image->GetOrigin() );
00196 this->SetOutputSpacing ( Image->GetSpacing() );
00197 this->SetOutputDirection ( Image->GetDirection() );
00198 this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00199 }
00201
00204 itkSetMacro( OutputStartIndex, IndexType );
00205
00207 itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00208
00213 void SetReferenceImage ( const TOutputImage *image );
00214 const TOutputImage * GetReferenceImage() const;
00216
00217 itkSetMacro(UseReferenceImage, bool);
00218 itkBooleanMacro(UseReferenceImage);
00219 itkGetMacro(UseReferenceImage, bool);
00220
00226 virtual void GenerateOutputInformation();
00227
00233 virtual void GenerateInputRequestedRegion();
00234
00237 virtual void BeforeThreadedGenerateData();
00238
00241 virtual void AfterThreadedGenerateData();
00242
00244 unsigned long GetMTime( void ) const;
00245
00246 #ifdef ITK_USE_CONCEPT_CHECKING
00247
00248 itkConceptMacro(OutputHasNumericTraitsCheck,
00249 (Concept::HasNumericTraits<PixelType>));
00250
00252 #endif
00253
00254 protected:
00255 ResampleImageFilter();
00256 ~ResampleImageFilter() {};
00257 void PrintSelf(std::ostream& os, Indent indent) const;
00258
00267 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00268 int threadId );
00269
00272 void NonlinearThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00273 int threadId );
00274
00278 void LinearThreadedGenerateData(const OutputImageRegionType&
00279 outputRegionForThread,
00280 int threadId );
00281
00282
00283 private:
00284 ResampleImageFilter(const Self&);
00285 void operator=(const Self&);
00286
00287 SizeType m_Size;
00288 TransformPointerType m_Transform;
00289 InterpolatorPointerType m_Interpolator;
00290
00291 PixelType m_DefaultPixelValue;
00292
00293
00294 SpacingType m_OutputSpacing;
00295 OriginPointType m_OutputOrigin;
00296 DirectionType m_OutputDirection;
00297 IndexType m_OutputStartIndex;
00298 bool m_UseReferenceImage;
00299
00300 };
00301
00302
00303 }
00304
00305 #ifndef ITK_MANUAL_INSTANTIATION
00306 #include "itkResampleImageFilter.txx"
00307 #endif
00308
00309 #endif
00310