]> Creatis software - clitk.git/blob - itk/clitkResampleImageWithOptionsFilter.h
Remove vnl_math dependency into registration codes
[clitk.git] / itk / clitkResampleImageWithOptionsFilter.h
1 /*=========================================================================
2   Program:   vv                     http://www.creatis.insa-lyon.fr/rio/vv
3
4   Authors belong to: 
5   - University of LYON              http://www.universite-lyon.fr/
6   - Léon Bérard cancer center       http://www.centreleonberard.fr
7   - CREATIS CNRS laboratory         http://www.creatis.insa-lyon.fr
8
9   This software is distributed WITHOUT ANY WARRANTY; without even
10   the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   PURPOSE.  See the copyright notices for more information.
12
13   It is distributed under dual licence
14
15   - BSD        See included LICENSE.txt file
16   - CeCILL-B   http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17   ===========================================================================**/
18
19 #ifndef CLITKRESAMPLEIMAGEWITHOPTIONSFILTER_H
20 #define CLITKRESAMPLEIMAGEWITHOPTIONSFILTER_H
21
22 #include "itkImageToImageFilter.h"
23 #include "itkAffineTransform.h"
24
25 #include "clitkCommon.h"
26
27 namespace clitk {
28   
29   //--------------------------------------------------------------------
30   /*
31     Image resampling with several interpolations and Gaussian filtering included.
32   */
33   //-------------------------------------------------------------------- 
34   template <class InputImageType, class OutputImageType=InputImageType>
35     class ITK_EXPORT ResampleImageWithOptionsFilter: 
36   public itk::ImageToImageFilter<InputImageType, OutputImageType> {
37
38   public:
39   /** Standard class typedefs. */
40   typedef ResampleImageWithOptionsFilter                     Self;
41   typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
42   typedef itk::SmartPointer<Self>                            Pointer;
43   typedef itk::SmartPointer<const Self>                      ConstPointer;
44     
45   /** Method for creation through the object factory. */
46   itkNewMacro(Self);
47     
48   /** Run-time type information (and related methods). */
49   itkTypeMacro(ResampleImageWithOptionsFilter, ImageToImageFilter);
50
51   /** Some convenient typedefs. */
52   typedef typename InputImageType::ConstPointer InputImageConstPointer;
53   typedef typename InputImageType::Pointer      InputImagePointer;
54   typedef typename InputImageType::RegionType   InputImageRegionType; 
55   typedef typename InputImageType::PixelType    InputImagePixelType;
56   typedef typename InputImageType::SpacingType  InputImageSpacingType;
57   typedef typename InputImageType::SizeType     InputImageSizeType;
58     
59   typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
60   typedef typename OutputImageType::Pointer      OutputImagePointer;
61   typedef typename OutputImageType::RegionType   OutputImageRegionType; 
62   typedef typename OutputImageType::PixelType    OutputImagePixelType;
63   typedef typename OutputImageType::SpacingType  OutputImageSpacingType;
64   typedef typename OutputImageType::SizeType     OutputImageSizeType;
65   typedef typename OutputImageType::PointType    OutputImageOriginType;
66   typedef typename OutputImageType::DirectionType        OutputImageDirectionType;
67     
68   typedef itk::AffineTransform<double, InputImageType::ImageDimension> TransformType;
69   typedef typename InputImageType::SpacingType                         GaussianSigmaType;
70
71   /** Interpolation types */
72   typedef enum {
73     NearestNeighbor = 0,
74     Linear = 1, 
75     BSpline = 2, 
76     B_LUT = 3,
77     WSINC = 4
78   } InterpolationTypeEnumeration;
79
80   /** ImageDimension constants */
81   itkStaticConstMacro(InputImageDimension, unsigned int,
82                       InputImageType::ImageDimension);
83   itkStaticConstMacro(OutputImageDimension, unsigned int,
84                       OutputImageType::ImageDimension);
85   itkConceptMacro(SameDimensionCheck,
86                   (itk::Concept::SameDimension<InputImageDimension, OutputImageDimension>));
87
88   /** Input : image to resample */
89   void SetInput(const InputImageType * image) ITK_OVERRIDE;
90     
91   /** ImageDimension constants */
92   itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
93
94   // Options
95   itkGetMacro(LastDimensionIsTime, bool);
96   itkSetMacro(LastDimensionIsTime, bool);
97   itkSetMacro(OutputIsoSpacing, double);
98   itkGetMacro(OutputIsoSpacing, double);
99   itkSetMacro(OutputSpacing, OutputImageSpacingType);
100   itkGetMacro(OutputSpacing, OutputImageSpacingType);
101   itkSetMacro(OutputSize, OutputImageSizeType);
102   itkGetMacro(OutputSize, OutputImageSizeType);
103   itkSetMacro(OutputOrigin, OutputImageOriginType);
104   itkGetMacro(OutputOrigin, OutputImageOriginType);
105   itkSetMacro(OutputDirection, OutputImageDirectionType);
106   itkGetMacro(OutputDirection, OutputImageDirectionType);
107   itkGetMacro(InterpolationType, InterpolationTypeEnumeration);
108   itkSetMacro(InterpolationType, InterpolationTypeEnumeration);    
109   itkGetMacro(GaussianFilteringEnabled, bool);
110   itkSetMacro(GaussianFilteringEnabled, bool);
111   itkGetMacro(BSplineOrder, int);
112   itkSetMacro(BSplineOrder, int);
113   itkGetMacro(BLUTSamplingFactor, int);
114   itkSetMacro(BLUTSamplingFactor, int);
115   itkGetMacro(Transform, typename TransformType::Pointer);
116   itkSetMacro(Transform, typename TransformType::Pointer);
117   itkGetMacro(GaussianSigma, GaussianSigmaType);
118   itkSetMacro(GaussianSigma, GaussianSigmaType);
119   itkGetMacro(DefaultPixelValue, OutputImagePixelType);
120   itkSetMacro(DefaultPixelValue, OutputImagePixelType);
121   itkGetMacro(VerboseOptions, bool);
122   itkSetMacro(VerboseOptions, bool);
123     
124   protected:
125   ResampleImageWithOptionsFilter();
126   virtual ~ResampleImageWithOptionsFilter() {}
127     
128   bool m_LastDimensionIsTime;
129   double m_OutputIsoSpacing;
130   InterpolationTypeEnumeration m_InterpolationType;
131   bool m_GaussianFilteringEnabled;
132   int m_BSplineOrder;
133   int m_BLUTSamplingFactor;    
134   OutputImageSizeType m_OutputSize;
135   OutputImageSpacingType m_OutputSpacing;
136   OutputImageOriginType    m_OutputOrigin;
137   OutputImageDirectionType m_OutputDirection;
138   typename TransformType::Pointer m_Transform;
139   GaussianSigmaType m_GaussianSigma;
140   OutputImagePixelType m_DefaultPixelValue;
141   bool m_VerboseOptions;
142   OutputImageRegionType m_OutputRegion;
143
144   virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
145   virtual void GenerateOutputInformation() ITK_OVERRIDE;
146   virtual void GenerateData() ITK_OVERRIDE;
147     
148   private:
149   ResampleImageWithOptionsFilter(const Self&); //purposely not implemented
150   void operator=(const Self&); //purposely not implemented
151     
152   }; // end class
153   //--------------------------------------------------------------------
154
155   // Convenient function 
156   template<class InputImageType>
157     typename InputImageType::Pointer ResampleImageSpacing(typename InputImageType::Pointer input, 
158                                                           typename InputImageType::SpacingType spacing, 
159                                                           int interpolationType=0);
160
161 } // end namespace clitk
162 //--------------------------------------------------------------------
163
164 #ifndef ITK_MANUAL_INSTANTIATION
165 #include "clitkResampleImageWithOptionsFilter.txx"
166 #endif
167
168 #endif