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

itkOptResampleImageFilter.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkOptResampleImageFilter.h,v $
00005   Language:  C++
00006   Date:      $Date: 2008-02-07 15:07:57 $
00007   Version:   $Revision: 1.4 $
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 __itkOptResampleImageFilter_h
00018 #define __itkOptResampleImageFilter_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 "itkLinearInterpolateImageFunction.h"
00027 #include "itkBSplineInterpolateImageFunction.h"
00028 #include "itkSize.h"
00029 
00030 namespace itk
00031 {
00032 
00071 template <class TInputImage,
00072           class TOutputImage,
00073           class TInterpolatorPrecisionType=double>
00074 class ITK_EXPORT ResampleImageFilter:
00075     public ImageToImageFilter<TInputImage, TOutputImage>
00076 {
00077 public:
00079   typedef ResampleImageFilter                           Self;
00080   typedef ImageToImageFilter<TInputImage,TOutputImage>  Superclass;
00081   typedef SmartPointer<Self>                            Pointer;
00082   typedef SmartPointer<const Self>                      ConstPointer;
00083 
00084   typedef TInputImage                             InputImageType;
00085   typedef TOutputImage                            OutputImageType;
00086   typedef typename InputImageType::Pointer        InputImagePointer;
00087   typedef typename InputImageType::ConstPointer   InputImageConstPointer;
00088   typedef typename OutputImageType::Pointer       OutputImagePointer;
00089   typedef typename InputImageType::RegionType     InputImageRegionType;
00090 
00092   itkNewMacro(Self);
00093 
00095   itkTypeMacro(ResampleImageFilter, ImageToImageFilter);
00096 
00098   itkStaticConstMacro(ImageDimension, unsigned int,
00099                       TOutputImage::ImageDimension);
00100   itkStaticConstMacro(InputImageDimension, unsigned int,
00101                       TInputImage::ImageDimension);
00103 
00104 
00108   typedef Transform<TInterpolatorPrecisionType,
00109                     itkGetStaticConstMacro(ImageDimension),
00110                     itkGetStaticConstMacro(ImageDimension)>       TransformType;
00111   typedef typename TransformType::ConstPointer             TransformPointerType;
00113 
00115   typedef InterpolateImageFunction<InputImageType,
00116                         TInterpolatorPrecisionType>     InterpolatorType;
00117   typedef typename InterpolatorType::Pointer            InterpolatorPointerType;
00118 
00119   typedef LinearInterpolateImageFunction<InputImageType,
00120                 TInterpolatorPrecisionType>   LinearInterpolatorType;
00121   typedef typename LinearInterpolatorType::Pointer
00122                                               LinearInterpolatorPointerType;
00123 
00124   typedef BSplineInterpolateImageFunction<InputImageType,
00125                 TInterpolatorPrecisionType>   BSplineInterpolatorType;
00126   typedef typename BSplineInterpolatorType::Pointer
00127                                               BSplineInterpolatorPointerType;
00128 
00130   typedef Size<itkGetStaticConstMacro(ImageDimension)>  SizeType;
00131 
00133   typedef typename TOutputImage::IndexType              IndexType;
00134 
00136   typedef typename InterpolatorType::PointType          PointType;
00137   //typedef typename TOutputImage::PointType            PointType;
00138 
00140   typedef typename TOutputImage::PixelType              PixelType;
00141   typedef typename TInputImage::PixelType               InputPixelType;
00142 
00144   typedef typename TOutputImage::RegionType             OutputImageRegionType;
00145 
00147   typedef typename TOutputImage::SpacingType            SpacingType;
00148   typedef typename TOutputImage::PointType              OriginPointType;
00149   typedef typename TOutputImage::DirectionType          DirectionType;
00150 
00158   itkSetConstObjectMacro( Transform, TransformType );
00159 
00161   itkGetConstObjectMacro( Transform, TransformType );
00162 
00170   itkSetObjectMacro( Interpolator, InterpolatorType );
00171 
00173   itkGetConstObjectMacro( Interpolator, InterpolatorType );
00174 
00176   itkSetMacro( Size, SizeType );
00177 
00179   itkGetConstReferenceMacro( Size, SizeType );
00180 
00183   itkSetMacro(DefaultPixelValue,PixelType);
00184 
00186   itkGetMacro(DefaultPixelValue,PixelType);
00187 
00189   itkSetMacro(OutputSpacing, SpacingType);
00190   virtual void SetOutputSpacing( const double* values);
00192 
00194   itkGetConstReferenceMacro( OutputSpacing, SpacingType );
00195 
00197   itkSetMacro(OutputOrigin, OriginPointType);
00198   virtual void SetOutputOrigin( const double* values);
00200 
00202   itkGetConstReferenceMacro( OutputOrigin, OriginPointType );
00203 
00205   itkSetMacro(OutputDirection, DirectionType);
00206   itkGetConstReferenceMacro(OutputDirection, DirectionType);
00208 
00210   void SetOutputParametersFromImage ( typename OutputImageType::Pointer Image )
00211     {
00212     this->SetOutputOrigin ( Image->GetOrigin() );
00213     this->SetOutputSpacing ( Image->GetSpacing() );
00214     this->SetOutputDirection ( Image->GetDirection() );
00215     this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00216     }
00218 
00221   itkSetMacro( OutputStartIndex, IndexType );
00222 
00224   itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00225 
00231   void SetReferenceImage ( const TOutputImage *image );
00232   const TOutputImage * GetReferenceImage() const;
00234 
00235   itkSetMacro(UseReferenceImage, bool);
00236   itkBooleanMacro(UseReferenceImage);
00237   itkGetMacro(UseReferenceImage, bool);
00238 
00244   virtual void GenerateOutputInformation();
00245 
00251   virtual void GenerateInputRequestedRegion();
00252 
00255   virtual void BeforeThreadedGenerateData();
00256 
00259   virtual void AfterThreadedGenerateData();
00260 
00262   unsigned long GetMTime( void ) const;
00263 
00264 #ifdef ITK_USE_CONCEPT_CHECKING
00265 
00266   itkConceptMacro(OutputHasNumericTraitsCheck,
00267                   (Concept::HasNumericTraits<PixelType>));
00268 
00270 #endif
00271 
00272 protected:
00273   ResampleImageFilter();
00274   ~ResampleImageFilter() {};
00275   void PrintSelf(std::ostream& os, Indent indent) const;
00276 
00286   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00287                             int threadId );
00288 
00291   void NonlinearThreadedGenerateData(const OutputImageRegionType &
00292                                            outputRegionForThread,
00293                                      int threadId );
00294 
00298   void LinearThreadedGenerateData(const OutputImageRegionType &
00299                                         outputRegionForThread,
00300                                   int threadId );
00301 
00302 
00303 private:
00304   ResampleImageFilter(const Self&); //purposely not implemented
00305   void operator=(const Self&); //purposely not implemented
00306 
00307   SizeType                m_Size;              // Size of the output image
00308   TransformPointerType    m_Transform;         // Coordinate transform to use
00309   InterpolatorPointerType m_Interpolator;      // Image function for
00310                                                // interpolation
00311   PixelType               m_DefaultPixelValue; // default pixel value
00312                                                // if the point is
00313                                                // outside the image
00314   SpacingType             m_OutputSpacing;     // output image spacing
00315   OriginPointType         m_OutputOrigin;      // output image origin
00316   DirectionType           m_OutputDirection;   // output image direction cosines
00317   IndexType               m_OutputStartIndex;  // output image start index
00318   bool                    m_UseReferenceImage;
00319 
00320   bool                             m_InterpolatorIsLinear;
00321   LinearInterpolatorPointerType    m_LinearInterpolator;
00322   bool                             m_InterpolatorIsBSpline;
00323   BSplineInterpolatorPointerType   m_BSplineInterpolator;
00324 
00325 };
00326 
00327 
00328 } // end namespace itk
00329 
00330 #ifndef ITK_MANUAL_INSTANTIATION
00331 #include "itkOptResampleImageFilter.txx"
00332 #endif
00333 
00334 #endif
00335 

Generated at Mon Apr 14 13:52:21 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000