1 // -------------------------------------------------------------------------
2 // @author Leonardo Florez-Valencia (florez-l@javeriana.edu.co)
3 // -------------------------------------------------------------------------
5 #ifndef __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__
6 #define __CPEXTENSIONS__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>
17 namespace cpExtensions
23 template< class R, class I >
25 : public itk::ImageToImageFilter< typename R::InputImageType, itk::Image< typename R::InputImageType::PixelType, R::ImageDimension - 1 > >
29 typedef BaseImageSlicer Self;
31 typedef I TInterpolateFunction;
32 typedef typename R::InputImageType TImage;
33 typedef typename I::CoordRepType TScalar;
34 typedef typename TImage::PixelType TPixel;
37 Dim = TImage::ImageDimension,
38 SliceDim = TImage::ImageDimension - 1
40 typedef itk::Image< TPixel, Self::SliceDim > TSliceImage;
43 typedef itk::ImageToImageFilter< TImage, TSliceImage > Superclass;
44 typedef itk::SmartPointer< Self > Pointer;
45 typedef itk::SmartPointer< const Self > ConstPointer;
48 typedef itk::ExtractImageFilter< TImage, TSliceImage > TCollapsor;
51 typedef typename TImage::IndexType TIndex;
52 typedef typename TImage::RegionType TRegion;
53 typedef typename TImage::SizeType TSize;
54 typedef typename TImage::SpacingType TSpacing;
55 typedef typename TSpacing::ValueType TSpacingValue;
57 typedef itk::AffineTransform< TScalar, Self::Dim > TTransform;
58 typedef typename TTransform::MatrixType TMatrix;
59 typedef typename TTransform::OffsetType TVector;
63 itkTypeMacro( BaseImageSlicer, itkImageToImageFilter );
65 itkBooleanMacro( SizeFromMaximum );
66 itkBooleanMacro( SizeFromMinimum );
67 itkBooleanMacro( SpacingFromMaximum );
68 itkBooleanMacro( SpacingFromMinimum );
70 itkGetConstObjectMacro( Transform, TTransform );
71 itkGetConstMacro( DefaultValue, TPixel );
72 itkGetConstMacro( Size, TVector );
73 itkGetConstMacro( SizeFromMaximum, bool );
74 itkGetConstMacro( SizeFromMinimum, bool );
75 itkGetConstMacro( Spacing, TSpacingValue );
76 itkGetConstMacro( SpacingFromMaximum, bool );
77 itkGetConstMacro( SpacingFromMinimum, bool );
79 itkSetObjectMacro( Transform, TTransform );
80 itkSetMacro( Size, TVector );
81 itkSetMacro( DefaultValue, TPixel );
82 itkSetMacro( SizeFromMaximum, bool );
83 itkSetMacro( SizeFromMinimum, bool );
84 itkSetMacro( Spacing, TSpacingValue );
85 itkSetMacro( SpacingFromMaximum, bool );
86 itkSetMacro( SpacingFromMinimum, bool );
89 virtual unsigned long GetMTime( ) const;
91 const TInterpolateFunction* GetInterpolator( ) const;
92 const TMatrix& GetRotation( ) const;
93 const TVector& GetTranslation( ) const;
95 void SetInterpolator( TInterpolateFunction* f );
98 void SetRotation( const M& r );
101 void SetTranslation( const V& t );
102 void SetSize( TScalar s );
106 virtual ~BaseImageSlicer( );
108 virtual void GenerateOutputInformation( ); // TODO { }
109 virtual void GenerateInputRequestedRegion( );
110 virtual void GenerateData( );
113 // Purposely not implemented
114 BaseImageSlicer( const Self& );
115 void operator=( const Self& );
118 typename TSlicer::Pointer m_Slicer;
119 typename TCollapsor::Pointer m_Collapsor;
120 typename TTransform::Pointer m_Transform;
122 TPixel m_DefaultValue;
125 bool m_SizeFromMaximum;
126 bool m_SizeFromMinimum;
128 TSpacingValue m_Spacing;
129 bool m_SpacingFromMaximum;
130 bool m_SpacingFromMinimum;
137 // -------------------------------------------------------------------------
138 #define CPPLUGINS_DEFINE_ISOIMAGESLICER( name, R, F ) \
139 template< class I, class S = double > \
141 : public BaseImageSlicer< R< I, I, S >, F< I, S > > \
144 typedef BaseImageSlicer< R< I, I, S >, F< I, S > > Superclass; \
146 typedef itk::SmartPointer< Self > Pointer; \
147 typedef itk::SmartPointer< const Self > ConstPointer; \
149 itkNewMacro( Self ); \
150 itkTypeMacro( name, BaseSlicer ); \
152 name( ) : Superclass( ) { } \
153 virtual ~name( ) { } \
155 name( const Self& ); \
156 void operator=( const Self& ); \
159 namespace cpExtensions
163 CPPLUGINS_DEFINE_ISOIMAGESLICER(
165 itk::ResampleImageFilter,
166 itk::InterpolateImageFunction
168 CPPLUGINS_DEFINE_ISOIMAGESLICER(
169 VectorIsoImageSlicer,
170 itk::VectorResampleImageFilter,
171 itk::VectorInterpolateImageFunction
178 #ifndef ITK_MANUAL_INSTANTIATION
179 #include <cpExtensions/Algorithms/IsoImageSlicer.hxx>
180 #endif // ITK_MANUAL_INSTANTIATION
182 #endif // __CPEXTENSIONS__ALGORITHMS__ISOIMAGESLICER__H__