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: 2005/07/27 15:21:11 $
00007   Version:   $Revision: 1.40 $
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   typedef TInputImage InputImageType;
00079   typedef TOutputImage OutputImageType;
00080   typedef typename InputImageType::Pointer InputImagePointer;
00081   typedef typename OutputImageType::Pointer OutputImagePointer;
00082   typedef typename InputImageType::RegionType InputImageRegionType;
00083 
00085   itkNewMacro(Self);  
00086 
00088   itkTypeMacro(ResampleImageFilter, ImageToImageFilter);
00089 
00091   itkStaticConstMacro(ImageDimension, unsigned int,
00092                       TOutputImage::ImageDimension);
00093 
00099   typedef Transform<TInterpolatorPrecisionType, itkGetStaticConstMacro(ImageDimension), itkGetStaticConstMacro(ImageDimension)> TransformType;
00100   typedef typename TransformType::ConstPointer TransformPointerType;
00101 
00103   typedef InterpolateImageFunction<InputImageType, TInterpolatorPrecisionType> InterpolatorType;
00104   typedef typename InterpolatorType::Pointer  InterpolatorPointerType;
00105 
00107   typedef Size<itkGetStaticConstMacro(ImageDimension)> SizeType;
00108 
00110   typedef typename TOutputImage::IndexType IndexType;
00111 
00113   typedef typename InterpolatorType::PointType    PointType;
00114   //typedef typename TOutputImage::PointType    PointType;
00115 
00117   typedef typename TOutputImage::PixelType   PixelType;
00118 
00120   typedef typename TOutputImage::RegionType OutputImageRegionType;
00121 
00123   typedef typename TOutputImage::SpacingType SpacingType;
00124   typedef typename TOutputImage::PointType   OriginPointType;
00125   typedef typename TInputImage::DirectionType DirectionType;
00126   
00132   itkSetConstObjectMacro( Transform, TransformType ); 
00133 
00135   itkGetConstObjectMacro( Transform, TransformType );
00136 
00143   itkSetObjectMacro( Interpolator, InterpolatorType );
00144 
00146   itkGetConstObjectMacro( Interpolator, InterpolatorType );
00147 
00149   itkSetMacro( Size, SizeType );
00150 
00152   itkGetConstReferenceMacro( Size, SizeType );
00153      
00156   itkSetMacro(DefaultPixelValue,PixelType);
00157 
00159   itkGetMacro(DefaultPixelValue,PixelType);
00160 
00162   itkSetMacro(OutputSpacing, SpacingType);
00163   virtual void SetOutputSpacing( const double* values);
00164 
00166   itkGetConstReferenceMacro( OutputSpacing, SpacingType );
00167 
00169   itkSetMacro(OutputOrigin, PointType);
00170   virtual void SetOutputOrigin( const double* values);
00171 
00173   itkGetConstReferenceMacro( OutputOrigin, PointType );
00174 
00176   itkSetMacro(OutputDirection, DirectionType);
00177   itkGetConstReferenceMacro(OutputDirection, DirectionType);
00178 
00180   void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image ) {
00181     this->SetOutputOrigin ( Image->GetOrigin() );
00182     this->SetOutputSpacing ( Image->GetSpacing() );
00183     this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00184   }
00185 
00188   itkSetMacro( OutputStartIndex, IndexType );
00189 
00191   itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00192 
00197   void SetReferenceImage (TOutputImage *image)
00198   {
00199     if (image != m_ReferenceImage)
00200       {
00201       m_ReferenceImage = image;
00202       this->ProcessObject::SetNthInput(1, image);
00203       this->Modified();
00204       }
00205   }
00206   itkGetObjectMacro(ReferenceImage, TOutputImage);
00207 
00208   itkSetMacro(UseReferenceImage, bool);
00209   itkBooleanMacro(UseReferenceImage);
00210   itkGetMacro(UseReferenceImage, bool);
00211 
00217   virtual void GenerateOutputInformation();
00218 
00224   virtual void GenerateInputRequestedRegion();
00225 
00228   virtual void BeforeThreadedGenerateData();
00229 
00232   virtual void AfterThreadedGenerateData();
00233 
00235   unsigned long GetMTime( void ) const;
00236 
00237 protected:
00238   ResampleImageFilter();
00239   ~ResampleImageFilter() {};
00240   void PrintSelf(std::ostream& os, Indent indent) const;
00241 
00250   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00251                             int threadId );
00252 
00253 private:
00254   ResampleImageFilter(const Self&); //purposely not implemented
00255   void operator=(const Self&); //purposely not implemented
00256 
00257   OutputImagePointer      m_ReferenceImage;
00258 
00259   SizeType                m_Size;       // Size of the output image
00260   TransformPointerType    m_Transform;  // Coordinate transform to use
00261   InterpolatorPointerType m_Interpolator; // Image function for interpolation
00262   PixelType               m_DefaultPixelValue; // default pixel value if the point 
00263                                                // is outside the image
00264   SpacingType             m_OutputSpacing; // output image spacing
00265   PointType               m_OutputOrigin;  // output image origin
00266   DirectionType           m_OutputDirection; // output image direction cosines
00267   IndexType               m_OutputStartIndex; // output image start index
00268   bool m_UseReferenceImage;
00269 
00270 };
00271 
00272   
00273 } // end namespace itk
00274   
00275 #ifndef ITK_MANUAL_INSTANTIATION
00276 #include "itkResampleImageFilter.txx"
00277 #endif
00278   
00279 #endif

Generated at Tue Aug 30 16:46:04 2005 for ITK by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2000