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

itkResampleImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkResampleImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-04-15 21:35:59 $
00007   Version:   $Revision: 1.56 $
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 __itkResampleImageFilter_h
00018 #define __itkResampleImageFilter_h
00019 
00020 // First make sure that the configuration is available.
00021 // This line can be removed once the optimized versions
00022 // gets integrated into the main directories.
00023 #include "itkConfigure.h"
00024 
00025 #ifdef ITK_USE_OPTIMIZED_REGISTRATION_METHODS
00026 #include "itkOptResampleImageFilter.h"
00027 #else
00028 
00029 #include "itkFixedArray.h"
00030 #include "itkTransform.h"
00031 #include "itkImageFunction.h"
00032 #include "itkImageRegionIterator.h"
00033 #include "itkImageToImageFilter.h"
00034 #include "itkInterpolateImageFunction.h"
00035 #include "itkSize.h"
00036 
00037 namespace itk
00038 {
00039 
00077 template <class TInputImage, class TOutputImage,
00078           class TInterpolatorPrecisionType=double>
00079 class ITK_EXPORT ResampleImageFilter:
00080     public ImageToImageFilter<TInputImage, TOutputImage>
00081 {
00082 public:
00084   typedef ResampleImageFilter                           Self;
00085   typedef ImageToImageFilter<TInputImage,TOutputImage>  Superclass;
00086   typedef SmartPointer<Self>                            Pointer;
00087   typedef SmartPointer<const Self>                      ConstPointer;
00088 
00089   typedef TInputImage                             InputImageType;
00090   typedef TOutputImage                            OutputImageType;
00091   typedef typename InputImageType::Pointer        InputImagePointer;
00092   typedef typename InputImageType::ConstPointer   InputImageConstPointer;
00093   typedef typename OutputImageType::Pointer       OutputImagePointer;
00094   typedef typename InputImageType::RegionType     InputImageRegionType;
00095 
00097   itkNewMacro(Self);  
00098 
00100   itkTypeMacro(ResampleImageFilter, ImageToImageFilter);
00101 
00103   itkStaticConstMacro(ImageDimension, unsigned int,
00104                       TOutputImage::ImageDimension);
00105   itkStaticConstMacro(InputImageDimension, unsigned int,
00106                       TInputImage::ImageDimension);
00108 
00109 
00113   typedef Transform<TInterpolatorPrecisionType, 
00114     itkGetStaticConstMacro(ImageDimension), 
00115     itkGetStaticConstMacro(ImageDimension)> TransformType;
00116   typedef typename TransformType::ConstPointer TransformPointerType;
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   //typedef typename TOutputImage::PointType    PointType;
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 TOutputImage::DirectionType DirectionType;
00144 
00152   itkSetConstObjectMacro( Transform, TransformType ); 
00153 
00155   itkGetConstObjectMacro( Transform, TransformType );
00156 
00163   itkSetObjectMacro( Interpolator, InterpolatorType );
00164 
00166   itkGetConstObjectMacro( Interpolator, InterpolatorType );
00167 
00169   itkSetMacro( Size, SizeType );
00170 
00172   itkGetConstReferenceMacro( Size, SizeType );
00173 
00176   itkSetMacro( DefaultPixelValue, PixelType );
00177 
00179   itkGetMacro( DefaultPixelValue, PixelType );
00180 
00182   itkSetMacro( OutputSpacing, SpacingType );
00183   virtual void SetOutputSpacing( const double* values );
00185 
00187   itkGetConstReferenceMacro( OutputSpacing, SpacingType );
00188 
00190   itkSetMacro( OutputOrigin, OriginPointType );
00191   virtual void SetOutputOrigin( const double* values);
00193 
00195   itkGetConstReferenceMacro( OutputOrigin, OriginPointType );
00196 
00198   itkSetMacro( OutputDirection, DirectionType );
00199   itkGetConstReferenceMacro( OutputDirection, DirectionType );
00201 
00203   void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image )
00204     {
00205     this->SetOutputOrigin ( Image->GetOrigin() );
00206     this->SetOutputSpacing ( Image->GetSpacing() );
00207     this->SetOutputDirection ( Image->GetDirection() );
00208     this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00209     }
00211 
00213   void SetOutputParametersFromConstImage ( typename OutputImageType::ConstPointer Image )
00214     {
00215     this->SetOutputOrigin ( Image->GetOrigin() );
00216     this->SetOutputSpacing ( Image->GetSpacing() );
00217     this->SetOutputDirection ( Image->GetDirection() );
00218     this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00219     }
00221 
00224   itkSetMacro( OutputStartIndex, IndexType );
00225 
00227   itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00228 
00235   void SetReferenceImage ( const TOutputImage *image );
00236   const TOutputImage * GetReferenceImage( void ) const;
00238 
00239   itkSetMacro( UseReferenceImage, bool );
00240   itkBooleanMacro( UseReferenceImage );
00241   itkGetMacro( UseReferenceImage, bool );
00242 
00248   virtual void GenerateOutputInformation( void );
00249 
00255   virtual void GenerateInputRequestedRegion( void );
00256 
00259   virtual void BeforeThreadedGenerateData( void );
00260 
00263   virtual void AfterThreadedGenerateData( void );
00264 
00266   unsigned long GetMTime( void ) const;
00267 
00268 #ifdef ITK_USE_CONCEPT_CHECKING
00269 
00270   itkConceptMacro(OutputHasNumericTraitsCheck,
00271                   (Concept::HasNumericTraits<PixelType>));
00272 
00274 #endif
00275 
00276 protected:
00277   ResampleImageFilter( void );
00278   ~ResampleImageFilter( void ) {};
00279 
00280   void PrintSelf( std::ostream& os, Indent indent ) const;
00281 
00290   void ThreadedGenerateData( const OutputImageRegionType& outputRegionForThread,
00291                              int threadId );
00292 
00295   void NonlinearThreadedGenerateData( const OutputImageRegionType& outputRegionForThread,
00296                                       int threadId );
00297 
00301   void LinearThreadedGenerateData( const OutputImageRegionType&
00302                                    outputRegionForThread,
00303                                    int threadId );
00304 
00305 
00306 private:
00307   ResampleImageFilter( const Self& ); //purposely not implemented
00308   void operator=( const Self& ); //purposely not implemented
00309 
00310   SizeType                m_Size;              // Size of the output image
00311   TransformPointerType    m_Transform;         // Coordinate transform to use
00312   InterpolatorPointerType m_Interpolator;      // Image function for
00313                                                // interpolation
00314   PixelType               m_DefaultPixelValue; // default pixel value
00315                                                // if the point is
00316                                                // outside the image
00317   SpacingType             m_OutputSpacing;     // output image spacing
00318   OriginPointType         m_OutputOrigin;      // output image origin
00319   DirectionType           m_OutputDirection;   // output image direction cosines
00320   IndexType               m_OutputStartIndex;  // output image start index
00321   bool                    m_UseReferenceImage;
00322 
00323 };
00324 
00325   
00326 } // end namespace itk
00327   
00328 #ifndef ITK_MANUAL_INSTANTIATION
00329 #include "itkResampleImageFilter.txx"
00330 #endif
00331   
00332 #endif
00333   
00334 #endif
00335 
00336 

Generated at Tue Jul 29 22:03:54 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000