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 (TOutputImage *image)
00214 {
00215 if (image != m_ReferenceImage)
00216 {
00217 m_ReferenceImage = image;
00218 this->ProcessObject::SetNthInput(1, image);
00219 this->Modified();
00220 }
00221 }
00222 itkGetObjectMacro(ReferenceImage, TOutputImage);
00224
00225 itkSetMacro(UseReferenceImage, bool);
00226 itkBooleanMacro(UseReferenceImage);
00227 itkGetMacro(UseReferenceImage, bool);
00228
00234 virtual void GenerateOutputInformation();
00235
00241 virtual void GenerateInputRequestedRegion();
00242
00245 virtual void BeforeThreadedGenerateData();
00246
00249 virtual void AfterThreadedGenerateData();
00250
00252 unsigned long GetMTime( void ) const;
00253
00254 #ifdef ITK_USE_CONCEPT_CHECKING
00255
00256 itkConceptMacro(OutputHasNumericTraitsCheck,
00257 (Concept::HasNumericTraits<PixelType>));
00258
00260 #endif
00261
00262 protected:
00263 ResampleImageFilter();
00264 ~ResampleImageFilter() {};
00265 void PrintSelf(std::ostream& os, Indent indent) const;
00266
00275 void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00276 int threadId );
00277
00280 void NonlinearThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00281 int threadId );
00282
00286 void LinearThreadedGenerateData(const OutputImageRegionType&
00287 outputRegionForThread,
00288 int threadId );
00289
00290
00291 private:
00292 ResampleImageFilter(const Self&);
00293 void operator=(const Self&);
00294
00295 OutputImagePointer m_ReferenceImage;
00296
00297 SizeType m_Size;
00298 TransformPointerType m_Transform;
00299 InterpolatorPointerType m_Interpolator;
00300
00301 PixelType m_DefaultPixelValue;
00302
00303
00304 SpacingType m_OutputSpacing;
00305 OriginPointType m_OutputOrigin;
00306 DirectionType m_OutputDirection;
00307 IndexType m_OutputStartIndex;
00308 bool m_UseReferenceImage;
00309
00310 };
00311
00312
00313 }
00314
00315 #ifndef ITK_MANUAL_INSTANTIATION
00316 #include "itkResampleImageFilter.txx"
00317 #endif
00318
00319 #endif
00320