// ------------------------------------------------------------------------- // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co) // ------------------------------------------------------------------------- #ifndef __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__ #define __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__ #include #include #include #include #include #include #include #include namespace cpExtensions { namespace Algorithms { /** */ template< class R, class I > class BaseImageSlicer : public itk::ImageToImageFilter< typename R::InputImageType, itk::Image< typename R::InputImageType::PixelType, R::ImageDimension - 1 > > { public: // Basic types typedef BaseImageSlicer Self; typedef R TSlicer; typedef I TInterpolateFunction; typedef typename R::InputImageType TImage; typedef typename I::CoordRepType TScalar; typedef typename TImage::PixelType TPixel; enum { Dim = TImage::ImageDimension, SliceDim = TImage::ImageDimension - 1 }; typedef itk::Image< TPixel, Self::SliceDim > TSliceImage; // itk types typedef itk::ImageToImageFilter< TImage, TSliceImage > Superclass; typedef itk::SmartPointer< Self > Pointer; typedef itk::SmartPointer< const Self > ConstPointer; // Internal filters typedef itk::ExtractImageFilter< TImage, TSliceImage > TCollapsor; // Various types typedef typename TImage::IndexType TIndex; typedef typename TImage::RegionType TRegion; typedef typename TImage::SizeType TSize; typedef typename TImage::SpacingType TSpacing; typedef typename TSpacing::ValueType TSpacingValue; typedef itk::AffineTransform< TScalar, Self::Dim > TTransform; typedef typename TTransform::MatrixType TMatrix; typedef typename TTransform::OffsetType TVector; public: itkNewMacro( Self ); itkTypeMacro( BaseImageSlicer, itkImageToImageFilter ); itkBooleanMacro( SizeFromMaximum ); itkBooleanMacro( SizeFromMinimum ); itkBooleanMacro( SpacingFromMaximum ); itkBooleanMacro( SpacingFromMinimum ); itkGetConstObjectMacro( Transform, TTransform ); itkGetConstMacro( DefaultValue, TPixel ); itkGetConstMacro( Size, TVector ); itkGetConstMacro( SizeFromMaximum, bool ); itkGetConstMacro( SizeFromMinimum, bool ); itkGetConstMacro( Spacing, TSpacingValue ); itkGetConstMacro( SpacingFromMaximum, bool ); itkGetConstMacro( SpacingFromMinimum, bool ); itkSetObjectMacro( Transform, TTransform ); itkSetMacro( Size, TVector ); itkSetMacro( DefaultValue, TPixel ); itkSetMacro( SizeFromMaximum, bool ); itkSetMacro( SizeFromMinimum, bool ); itkSetMacro( Spacing, TSpacingValue ); itkSetMacro( SpacingFromMaximum, bool ); itkSetMacro( SpacingFromMinimum, bool ); public: virtual unsigned long GetMTime( ) const; const TInterpolateFunction* GetInterpolator( ) const; const TMatrix& GetRotation( ) const; const TVector& GetTranslation( ) const; void SetInterpolator( TInterpolateFunction* f ); template< class M > void SetRotation( const M& r ); template< class V > void SetTranslation( const V& t ); void SetSize( TScalar s ); protected: BaseImageSlicer( ); virtual ~BaseImageSlicer( ); virtual void GenerateOutputInformation( ); // TODO { } virtual void GenerateInputRequestedRegion( ); virtual void GenerateData( ); private: // Purposely not implemented BaseImageSlicer( const Self& ); void operator=( const Self& ); protected: typename TSlicer::Pointer m_Slicer; typename TCollapsor::Pointer m_Collapsor; typename TTransform::Pointer m_Transform; TPixel m_DefaultValue; TVector m_Size; bool m_SizeFromMaximum; bool m_SizeFromMinimum; TSpacingValue m_Spacing; bool m_SpacingFromMaximum; bool m_SpacingFromMinimum; }; } // ecapseman } // ecapseman // ------------------------------------------------------------------------- #define CPPLUGINS_DEFINE_ISOIMAGESLICER( name, R, F ) \ template< class I, class S = double > \ class name \ : public BaseImageSlicer< R< I, I, S >, F< I, S > > \ { \ public: \ typedef BaseImageSlicer< R< I, I, S >, F< I, S > > Superclass; \ typedef name Self; \ typedef itk::SmartPointer< Self > Pointer; \ typedef itk::SmartPointer< const Self > ConstPointer; \ public: \ itkNewMacro( Self ); \ itkTypeMacro( name, BaseSlicer ); \ protected: \ name( ) : Superclass( ) { } \ virtual ~name( ) { } \ private: \ name( const Self& ); \ void operator=( const Self& ); \ }; namespace cpExtensions { namespace Algorithms { CPPLUGINS_DEFINE_ISOIMAGESLICER( IsoImageSlicer, itk::ResampleImageFilter, itk::InterpolateImageFunction ); CPPLUGINS_DEFINE_ISOIMAGESLICER( VectorIsoImageSlicer, itk::VectorResampleImageFilter, itk::VectorInterpolateImageFunction ); } // ecapseman } // ecapseman #ifndef ITK_MANUAL_INSTANTIATION #include #endif // ITK_MANUAL_INSTANTIATION #endif // __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__ // eof - $RCSfile$