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