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-11-06 15:25:08 $
00007   Version:   $Revision: 1.6 $
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   itkGetConstReferenceMacro(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 
00220   void SetOutputParametersFromConstImage ( typename OutputImageType::ConstPointer Image )
00221     {
00222     this->SetOutputOrigin ( Image->GetOrigin() );
00223     this->SetOutputSpacing ( Image->GetSpacing() );
00224     this->SetOutputDirection ( Image->GetDirection() );
00225     this->SetSize ( Image->GetLargestPossibleRegion().GetSize() );
00226     }
00228 
00231   itkSetMacro( OutputStartIndex, IndexType );
00232 
00234   itkGetConstReferenceMacro( OutputStartIndex, IndexType );
00235 
00241   void SetReferenceImage ( const TOutputImage *image );
00242   const TOutputImage * GetReferenceImage() const;
00244 
00245   itkSetMacro(UseReferenceImage, bool);
00246   itkBooleanMacro(UseReferenceImage);
00247   itkGetMacro(UseReferenceImage, bool);
00248 
00254   virtual void GenerateOutputInformation();
00255 
00261   virtual void GenerateInputRequestedRegion();
00262 
00265   virtual void BeforeThreadedGenerateData();
00266 
00269   virtual void AfterThreadedGenerateData();
00270 
00272   unsigned long GetMTime( void ) const;
00273 
00274 #ifdef ITK_USE_CONCEPT_CHECKING
00275 
00276   itkConceptMacro(OutputHasNumericTraitsCheck,
00277                   (Concept::HasNumericTraits<PixelType>));
00278 
00280 #endif
00281 
00282 protected:
00283   ResampleImageFilter();
00284   ~ResampleImageFilter() {};
00285   void PrintSelf(std::ostream& os, Indent indent) const;
00286 
00296   void ThreadedGenerateData(const OutputImageRegionType& outputRegionForThread,
00297                             int threadId );
00298 
00301   void NonlinearThreadedGenerateData(const OutputImageRegionType &
00302                                            outputRegionForThread,
00303                                      int threadId );
00304 
00308   void LinearThreadedGenerateData(const OutputImageRegionType &
00309                                         outputRegionForThread,
00310                                   int threadId );
00311 
00312 
00313 private:
00314   ResampleImageFilter(const Self&); //purposely not implemented
00315   void operator=(const Self&); //purposely not implemented
00316 
00317   SizeType                m_Size;              // Size of the output image
00318   TransformPointerType    m_Transform;         // Coordinate transform to use
00319   InterpolatorPointerType m_Interpolator;      // Image function for
00320                                                // interpolation
00321   PixelType               m_DefaultPixelValue; // default pixel value
00322                                                // if the point is
00323                                                // outside the image
00324   SpacingType             m_OutputSpacing;     // output image spacing
00325   OriginPointType         m_OutputOrigin;      // output image origin
00326   DirectionType           m_OutputDirection;   // output image direction cosines
00327   IndexType               m_OutputStartIndex;  // output image start index
00328   bool                    m_UseReferenceImage;
00329 
00330   bool                             m_InterpolatorIsLinear;
00331   LinearInterpolatorPointerType    m_LinearInterpolator;
00332   bool                             m_InterpolatorIsBSpline;
00333   BSplineInterpolatorPointerType   m_BSplineInterpolator;
00334 
00335 };
00336 
00337 
00338 } // end namespace itk
00339 
00340 #ifndef ITK_MANUAL_INSTANTIATION
00341 #include "itkOptResampleImageFilter.txx"
00342 #endif
00343 
00344 #endif
00345 

Generated at Sat Feb 28 13:12:16 2009 for ITK by doxygen 1.5.6 written by Dimitri van Heesch, © 1997-2000