1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #ifndef __CPPLUGINS__EXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__
6 #define __CPPLUGINS__EXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__
8 #include <itkAffineTransform.h>
9 #include <itkExtractImageFilter.h>
11 #include <itkImageToImageFilter.h>
12 #include <itkInterpolateImageFunction.h>
13 #include <itkResampleImageFilter.h>
14 #include <itkVectorResampleImageFilter.h>
15 #include <itkVectorInterpolateImageFunction.h>
25 template< class R, class I >
27 : public itk::ImageToImageFilter< typename R::InputImageType, itk::Image< typename R::InputImageType::PixelType, R::ImageDimension - 1 > >
31 typedef BaseImageSlicer Self;
33 typedef I TInterpolateFunction;
34 typedef typename R::InputImageType TImage;
35 typedef typename I::CoordRepType TScalar;
36 typedef typename TImage::PixelType TPixel;
39 Dim = TImage::ImageDimension,
40 SliceDim = TImage::ImageDimension - 1
42 typedef itk::Image< TPixel, Self::SliceDim > TSliceImage;
45 typedef itk::ImageToImageFilter< TImage, TSliceImage > Superclass;
46 typedef itk::SmartPointer< Self > Pointer;
47 typedef itk::SmartPointer< const Self > ConstPointer;
50 typedef itk::ExtractImageFilter< TImage, TSliceImage > TCollapsor;
53 typedef typename TImage::IndexType TIndex;
54 typedef typename TImage::RegionType TRegion;
55 typedef typename TImage::SizeType TSize;
56 typedef typename TImage::SpacingType TSpacing;
57 typedef typename TSpacing::ValueType TSpacingValue;
59 typedef itk::AffineTransform< TScalar, Self::Dim > TTransform;
60 typedef typename TTransform::MatrixType TMatrix;
61 typedef typename TTransform::OffsetType TVector;
65 itkTypeMacro( BaseImageSlicer, itkImageToImageFilter );
67 itkBooleanMacro( SizeFromMaximum );
68 itkBooleanMacro( SizeFromMinimum );
69 itkBooleanMacro( SpacingFromMaximum );
70 itkBooleanMacro( SpacingFromMinimum );
72 itkGetConstObjectMacro( Transform, TTransform );
73 itkGetConstMacro( DefaultValue, TPixel );
74 itkGetConstMacro( Size, TVector );
75 itkGetConstMacro( SizeFromMaximum, bool );
76 itkGetConstMacro( SizeFromMinimum, bool );
77 itkGetConstMacro( Spacing, TSpacingValue );
78 itkGetConstMacro( SpacingFromMaximum, bool );
79 itkGetConstMacro( SpacingFromMinimum, bool );
81 itkSetObjectMacro( Transform, TTransform );
82 itkSetMacro( Size, TVector );
83 itkSetMacro( DefaultValue, TPixel );
84 itkSetMacro( SizeFromMaximum, bool );
85 itkSetMacro( SizeFromMinimum, bool );
86 itkSetMacro( Spacing, TSpacingValue );
87 itkSetMacro( SpacingFromMaximum, bool );
88 itkSetMacro( SpacingFromMinimum, bool );
91 virtual unsigned long GetMTime( ) const;
93 const TInterpolateFunction* GetInterpolator( ) const;
94 const TMatrix& GetRotation( ) const;
95 const TVector& GetTranslation( ) const;
97 void SetInterpolator( TInterpolateFunction* f );
100 void SetRotation( const M& r );
103 void SetTranslation( const V& t );
104 void SetSize( TScalar s );
108 virtual ~BaseImageSlicer( );
110 virtual void GenerateOutputInformation( ); // TODO { }
111 virtual void GenerateInputRequestedRegion( );
112 virtual void GenerateData( );
115 // Purposely not implemented
116 BaseImageSlicer( const Self& );
117 void operator=( const Self& );
120 typename TSlicer::Pointer m_Slicer;
121 typename TCollapsor::Pointer m_Collapsor;
122 typename TTransform::Pointer m_Transform;
124 TPixel m_DefaultValue;
127 bool m_SizeFromMaximum;
128 bool m_SizeFromMinimum;
130 TSpacingValue m_Spacing;
131 bool m_SpacingFromMaximum;
132 bool m_SpacingFromMinimum;
141 // -------------------------------------------------------------------------
142 #define CPPLUGINS_DEFINE_ISOIMAGESLICER( name, R, F ) \
143 template< class I, class S = double > \
145 : public BaseImageSlicer< R< I, I, S >, F< I, S > > \
148 typedef BaseImageSlicer< R< I, I, S >, F< I, S > > Superclass; \
150 typedef itk::SmartPointer< Self > Pointer; \
151 typedef itk::SmartPointer< const Self > ConstPointer; \
153 itkNewMacro( Self ); \
154 itkTypeMacro( name, BaseSlicer ); \
156 name( ) : Superclass( ) { } \
157 virtual ~name( ) { } \
159 name( const Self& ); \
160 void operator=( const Self& ); \
169 CPPLUGINS_DEFINE_ISOIMAGESLICER(
171 itk::ResampleImageFilter,
172 itk::InterpolateImageFunction
174 CPPLUGINS_DEFINE_ISOIMAGESLICER(
175 VectorIsoImageSlicer,
176 itk::VectorResampleImageFilter,
177 itk::VectorInterpolateImageFunction
185 #include <cpPlugins/Extensions/Algorithms/IsoImageSlicer.hxx>
187 #endif // __CPPLUGINS__EXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__