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: 2007/03/29 16:42:31 $
00007   Version:   $Revision: 1.52 $
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 #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   //typedef typename TOutputImage::PointType    PointType;
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&); //purposely not implemented
00285   void operator=(const Self&); //purposely not implemented
00286 
00287   SizeType                m_Size;              // Size of the output image
00288   TransformPointerType    m_Transform;         // Coordinate transform to use
00289   InterpolatorPointerType m_Interpolator;      // Image function for
00290                                                // interpolation
00291   PixelType               m_DefaultPixelValue; // default pixel value
00292                                                // if the point is
00293                                                // outside the image
00294   SpacingType             m_OutputSpacing;     // output image spacing
00295   OriginPointType         m_OutputOrigin;      // output image origin
00296   DirectionType           m_OutputDirection;   // output image direction cosines
00297   IndexType               m_OutputStartIndex;  // output image start index
00298   bool                    m_UseReferenceImage;
00299 
00300 };
00301 
00302   
00303 } // end namespace itk
00304   
00305 #ifndef ITK_MANUAL_INSTANTIATION
00306 #include "itkResampleImageFilter.txx"
00307 #endif
00308   
00309 #endif
00310 

Generated at Sun Sep 23 14:08:00 2007 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000