Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkWarpImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkWarpImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2009-04-25 12:28:12 $
00007   Version:   $Revision: 1.30 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012      This software is distributed WITHOUT ANY WARRANTY; without even 
00013      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00014      PURPOSE.  See the above copyright notices for more information.
00015 
00016 =========================================================================*/
00017 #ifndef __itkWarpImageFilter_h
00018 #define __itkWarpImageFilter_h
00019 #include "itkImageBase.h"
00020 #include "itkImageToImageFilter.h"
00021 #include "itkInterpolateImageFunction.h"
00022 #include "itkLinearInterpolateImageFunction.h"
00023 #include "itkPoint.h"
00024 #include "itkFixedArray.h"
00025 
00026 namespace itk
00027 {
00028 
00081 template <
00082   class TInputImage,
00083   class TOutputImage,
00084   class TDeformationField
00085   >
00086 class ITK_EXPORT WarpImageFilter :
00087     public ImageToImageFilter<TInputImage, TOutputImage>
00088 {
00089 public:
00091   typedef WarpImageFilter                              Self;
00092   typedef ImageToImageFilter<TInputImage,TOutputImage> Superclass;
00093   typedef SmartPointer<Self>                           Pointer;
00094   typedef SmartPointer<const Self>                     ConstPointer;
00095 
00097   itkNewMacro(Self);
00098 
00100   itkTypeMacro( WarpImageFilter, ImageToImageFilter );
00101 
00103   typedef typename TOutputImage::RegionType OutputImageRegionType;
00104 
00106   typedef typename Superclass::InputImageType         InputImageType;
00107   typedef typename Superclass::InputImagePointer      InputImagePointer;
00108   typedef typename Superclass::OutputImageType        OutputImageType;
00109   typedef typename Superclass::OutputImagePointer     OutputImagePointer;
00110   typedef typename Superclass::InputImageConstPointer InputImageConstPointer;
00111   typedef typename OutputImageType::IndexType         IndexType;
00112   typedef typename OutputImageType::SizeType          SizeType;
00113   typedef typename OutputImageType::PixelType         PixelType;
00114   typedef typename OutputImageType::SpacingType       SpacingType;
00115 
00117   itkStaticConstMacro(ImageDimension, unsigned int,
00118                       TOutputImage::ImageDimension );
00119   itkStaticConstMacro(InputImageDimension, unsigned int,
00120                       TInputImage::ImageDimension );
00121   itkStaticConstMacro(DeformationFieldDimension, unsigned int,
00122                       TDeformationField::ImageDimension );
00123 
00125   typedef ImageBase<itkGetStaticConstMacro(ImageDimension)> ImageBaseType;
00126 
00128   typedef TDeformationField                        DeformationFieldType;
00129   typedef typename DeformationFieldType::Pointer   DeformationFieldPointer;
00130   typedef typename DeformationFieldType::PixelType DisplacementType;
00131 
00133   typedef double                                                CoordRepType;
00134   typedef InterpolateImageFunction<InputImageType,CoordRepType> InterpolatorType;
00135   typedef typename InterpolatorType::Pointer                    InterpolatorPointer;
00136   typedef LinearInterpolateImageFunction<InputImageType,CoordRepType>
00137                                                                 DefaultInterpolatorType;
00138 
00140   typedef Point<CoordRepType,itkGetStaticConstMacro(ImageDimension)> PointType;
00141 
00143   typedef typename TOutputImage::DirectionType     DirectionType;
00144 
00146   void SetDeformationField( const DeformationFieldType * field );
00147 
00149   DeformationFieldType * GetDeformationField(void);
00150 
00152   itkSetObjectMacro( Interpolator, InterpolatorType );
00153 
00155   itkGetObjectMacro( Interpolator, InterpolatorType );
00156 
00158   itkSetMacro(OutputSpacing, SpacingType);
00159   virtual void SetOutputSpacing( const double* values);
00161 
00163   itkGetConstReferenceMacro(OutputSpacing, SpacingType);
00164 
00166   itkSetMacro(OutputOrigin, PointType);
00167   virtual void SetOutputOrigin( const double* values);
00169 
00171   itkGetConstReferenceMacro(OutputOrigin, PointType);
00172 
00174   itkSetMacro(OutputDirection, DirectionType );
00175   itkGetConstReferenceMacro(OutputDirection, DirectionType );
00177 
00179   void SetOutputParametersFromImage ( const ImageBaseType *image );
00180 
00183   itkSetMacro( OutputStartIndex, IndexType );
00184 
00186   itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00187 
00189   itkSetMacro( OutputSize, SizeType );
00190 
00192   itkGetConstReferenceMacro( OutputSize, SizeType );
00193 
00195   itkSetMacro( EdgePaddingValue, PixelType );
00196 
00198   itkGetConstMacro( EdgePaddingValue, PixelType );
00199 
00205   virtual void GenerateOutputInformation();
00206 
00213   virtual void GenerateInputRequestedRegion();
00214 
00217   virtual void BeforeThreadedGenerateData();
00218 
00221   virtual void AfterThreadedGenerateData();
00222 
00223 #ifdef ITK_USE_CONCEPT_CHECKING
00224 
00225   itkConceptMacro(SameDimensionCheck1,
00226     (Concept::SameDimension<ImageDimension, InputImageDimension>));
00227   itkConceptMacro(SameDimensionCheck2,
00228     (Concept::SameDimension<ImageDimension, DeformationFieldDimension>));
00229   itkConceptMacro(InputHasNumericTraitsCheck,
00230     (Concept::HasNumericTraits<typename TInputImage::PixelType>));
00231   itkConceptMacro(DeformationFieldHasNumericTraitsCheck,
00232     (Concept::HasNumericTraits<typename TDeformationField::PixelType::ValueType>));
00233 
00235 #endif
00236 
00237 protected:
00238   WarpImageFilter();
00239   ~WarpImageFilter() {};
00240   void PrintSelf(std::ostream& os, Indent indent) const;
00241 
00245   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00246                             int threadId );
00247 
00248 private:
00249   WarpImageFilter(const Self&); //purposely not implemented
00250   void operator=(const Self&); //purposely not implemented
00251 
00255   DisplacementType EvaluateDeformationAtPhysicalPoint(const PointType &p);
00256 
00257   PixelType                  m_EdgePaddingValue;
00258   SpacingType                m_OutputSpacing;
00259   PointType                  m_OutputOrigin;
00260   DirectionType              m_OutputDirection;
00261 
00262   InterpolatorPointer        m_Interpolator;
00263   SizeType                   m_OutputSize;        // Size of the output image
00264   IndexType                  m_OutputStartIndex;  // output image start index
00265   bool                       m_DefFieldSizeSame;
00266   // variables for deffield interpoator
00267   IndexType m_StartIndex,m_EndIndex;
00268 
00269 
00270 };
00271 
00272 } // end namespace itk
00273 
00274 #ifndef ITK_MANUAL_INSTANTIATION
00275 #include "itkWarpImageFilter.txx"
00276 #endif
00277 
00278 #endif
00279 

Generated at Tue Sep 15 05:28:17 2009 for ITK by doxygen 1.5.8 written by Dimitri van Heesch, © 1997-2000