]> Creatis software - clitk.git/blob - itk/clitkResampleImageWithOptionsFilter.h
Fix deprecated warning (Begin -> GoToBegin)
[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 namespace clitk {
26   
27   //--------------------------------------------------------------------
28   /*
29     Image resampling with several interpolations and Gaussian filtering included.
30   */
31   //-------------------------------------------------------------------- 
32   template <class InputImageType, class OutputImageType=InputImageType>
33     class ITK_EXPORT ResampleImageWithOptionsFilter: 
34   public itk::ImageToImageFilter<InputImageType, OutputImageType> {
35
36   public:
37   /** Standard class typedefs. */
38   typedef ResampleImageWithOptionsFilter                     Self;
39   typedef itk::ImageToImageFilter<InputImageType, OutputImageType> Superclass;
40   typedef itk::SmartPointer<Self>                            Pointer;
41   typedef itk::SmartPointer<const Self>                      ConstPointer;
42     
43   /** Method for creation through the object factory. */
44   itkNewMacro(Self);
45     
46   /** Run-time type information (and related methods). */
47   itkTypeMacro(ResampleImageWithOptionsFilter, ImageToImageFilter);
48
49   /** Some convenient typedefs. */
50   typedef typename InputImageType::ConstPointer InputImageConstPointer;
51   typedef typename InputImageType::Pointer      InputImagePointer;
52   typedef typename InputImageType::RegionType   InputImageRegionType; 
53   typedef typename InputImageType::PixelType    InputImagePixelType;
54   typedef typename InputImageType::SpacingType  InputImageSpacingType;
55   typedef typename InputImageType::SizeType     InputImageSizeType;
56     
57   typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
58   typedef typename OutputImageType::Pointer      OutputImagePointer;
59   typedef typename OutputImageType::RegionType   OutputImageRegionType; 
60   typedef typename OutputImageType::PixelType    OutputImagePixelType;
61   typedef typename OutputImageType::SpacingType  OutputImageSpacingType;
62   typedef typename OutputImageType::SizeType     OutputImageSizeType;
63     
64   typedef itk::AffineTransform<double, InputImageType::ImageDimension> TransformType;
65   typedef typename InputImageType::SpacingType                         GaussianSigmaType;
66
67   /** Interpolation types */
68   typedef enum {
69     NearestNeighbor = 0,
70     Linear = 1, 
71     BSpline = 2, 
72     B_LUT = 3,
73     WSINC = 4
74   } InterpolationTypeEnumeration;
75
76   /** ImageDimension constants */
77   itkStaticConstMacro(InputImageDimension, unsigned int,
78                       InputImageType::ImageDimension);
79   itkStaticConstMacro(OutputImageDimension, unsigned int,
80                       OutputImageType::ImageDimension);
81   itkConceptMacro(SameDimensionCheck,
82                   (itk::Concept::SameDimension<InputImageDimension, OutputImageDimension>));
83
84   /** Input : image to resample */
85   void SetInput(const InputImageType * image);
86     
87   /** ImageDimension constants */
88   itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
89
90   // Options
91   itkGetMacro(LastDimensionIsTime, bool);
92   itkSetMacro(LastDimensionIsTime, bool);
93   itkSetMacro(OutputIsoSpacing, double);
94   itkGetMacro(OutputIsoSpacing, double);
95   itkSetMacro(OutputSpacing, OutputImageSpacingType);
96   itkGetMacro(OutputSpacing, OutputImageSpacingType);
97   itkSetMacro(OutputSize, OutputImageSizeType);
98   itkGetMacro(OutputSize, OutputImageSizeType);
99   itkGetMacro(InterpolationType, InterpolationTypeEnumeration);
100   itkSetMacro(InterpolationType, InterpolationTypeEnumeration);    
101   itkGetMacro(GaussianFilteringEnabled, bool);
102   itkSetMacro(GaussianFilteringEnabled, bool);
103   itkGetMacro(BSplineOrder, int);
104   itkSetMacro(BSplineOrder, int);
105   itkGetMacro(BLUTSamplingFactor, int);
106   itkSetMacro(BLUTSamplingFactor, int);
107   itkGetMacro(Transform, typename TransformType::Pointer);
108   itkSetMacro(Transform, typename TransformType::Pointer);
109   itkGetMacro(GaussianSigma, GaussianSigmaType);
110   itkSetMacro(GaussianSigma, GaussianSigmaType);
111   itkGetMacro(DefaultPixelValue, OutputImagePixelType);
112   itkSetMacro(DefaultPixelValue, OutputImagePixelType);
113   itkGetMacro(VerboseOptions, bool);
114   itkSetMacro(VerboseOptions, bool);
115     
116   protected:
117   ResampleImageWithOptionsFilter();
118   virtual ~ResampleImageWithOptionsFilter() {}
119     
120   bool m_LastDimensionIsTime;
121   double m_OutputIsoSpacing;
122   InterpolationTypeEnumeration m_InterpolationType;
123   bool m_GaussianFilteringEnabled;
124   int m_BSplineOrder;
125   int m_BLUTSamplingFactor;    
126   OutputImageSizeType m_OutputSize;
127   OutputImageSpacingType m_OutputSpacing;  
128   typename TransformType::Pointer m_Transform;
129   GaussianSigmaType m_GaussianSigma;
130   OutputImagePixelType m_DefaultPixelValue;
131   bool m_VerboseOptions;
132   OutputImageRegionType m_OutputRegion;
133
134   virtual void GenerateInputRequestedRegion();
135   virtual void GenerateOutputInformation();
136   virtual void GenerateData();
137     
138   private:
139   ResampleImageWithOptionsFilter(const Self&); //purposely not implemented
140   void operator=(const Self&); //purposely not implemented
141     
142   }; // end class
143   //--------------------------------------------------------------------
144
145   // Convenient function 
146   template<class InputImageType>
147     typename InputImageType::Pointer ResampleImageSpacing(typename InputImageType::Pointer input, 
148                                                           typename InputImageType::SpacingType spacing, 
149                                                           int interpolationType=0);
150
151 } // end namespace clitk
152 //--------------------------------------------------------------------
153
154 #ifndef ITK_MANUAL_INSTANTIATION
155 #include "clitkResampleImageWithOptionsFilter.txx"
156 #endif
157
158 #endif