]> Creatis software - clitk.git/blob - tools/clitkVFResampleGenericFilter.h
With ITKv5, change VectorResample and VectorCast Image Filter to Resample and Cast...
[clitk.git] / tools / clitkVFResampleGenericFilter.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 #ifndef CLITKIMAGERESAMPLEGENERICFILTER_H
19 #define CLITKIMAGERESAMPLEGENERICFILTER_H
20 /**
21  -------------------------------------------------------------------
22  * @file   clitkVFResampleGenericFilter.h
23  * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
24  * @date   23 Feb 2008 08:37:53
25
26  * @brief  
27  -------------------------------------------------------------------*/
28
29 // clitk include
30 #include "clitkCommon.h"
31 #include "clitkImageCommon.h"
32 #include "clitkImageToImageGenericFilter.h"
33
34 // itk include
35 #include "itkImage.h"
36 #include "itkVectorImage.h"
37 #include "itkFixedArray.h"
38 #include "itkImageFileReader.h"
39 #include "itkImageSeriesReader.h"
40 #include "itkImageFileWriter.h"
41 #include "itkRecursiveGaussianImageFilter.h"
42 #if ( ITK_VERSION_MAJOR < 5 )
43 #include "itkVectorResampleImageFilter.h"
44 #include "itkVectorNearestNeighborInterpolateImageFunction.h"
45 #include "itkVectorLinearInterpolateImageFunction.h"
46 #else
47 #include "itkResampleImageFilter.h"
48 #include "itkNearestNeighborInterpolateImageFunction.h"
49 #include "itkLinearInterpolateImageFunction.h"
50 #endif
51 #include "itkAffineTransform.h"
52 #include "itkBSplineInterpolateImageFunction.h"
53 #include "itkBSplineInterpolateImageFunctionWithLUT.h"
54 #include "itkCommand.h"
55
56 namespace clitk {
57   
58   //--------------------------------------------------------------------
59   class VFResampleGenericFilter: 
60     public clitk::ImageToImageGenericFilter<VFResampleGenericFilter> {
61     
62   public: 
63     // constructor
64     VFResampleGenericFilter();
65
66     // Types
67     typedef VFResampleGenericFilter       Self;
68     typedef itk::SmartPointer<Self>       Pointer;
69     typedef itk::SmartPointer<const Self> ConstPointer;
70
71     // New
72     itkNewMacro(Self);
73     
74     void SetOutputSize(const std::vector<int> & size);
75     void SetOutputSpacing(const std::vector<double> & spacing);
76     void SetGaussianSigma(const std::vector<double> & sigma);
77     void SetInterpolationName(const std::string & inter);
78     void SetDefaultPixelValue(double dpv) { mDefaultPixelValue = dpv;}
79     void SetBSplineOrder(int o) { mBSplineOrder = o; }
80     void SetBLUTSampling(int b) { mSamplingFactors.resize(1); mSamplingFactors[0] = b; }
81
82    //--------------------------------------------------------------------
83     // Main function called each time the filter is updated
84     template<class InputImageType>  
85     void UpdateWithInputImageType();
86
87   protected:
88     template<unsigned int Dim> void InitializeImageType();
89     //--------------------------------------------------------------------
90     std::string mInterpolatorName;
91     std::vector<int> mOutputSize;
92     std::vector<double> mOutputSpacing;
93     std::vector<double> mOutputOrigin;
94     double mDefaultPixelValue;
95     bool mApplyGaussianFilterBefore;
96     std::vector<double> mSigma;
97     int mBSplineOrder;
98     std::vector<int> mSamplingFactors;
99
100     //--------------------------------------------------------------------
101     template<unsigned int Dim, class PixelType, unsigned int DimCompo> 
102     void Update_WithDimAndPixelTypeAndComponent();
103     template<class ImageType>
104     typename ImageType::Pointer ComputeImage(typename ImageType::Pointer inputImage);
105     
106   }; // end class VFResampleGenericFilter
107   //--------------------------------------------------------------------
108     
109 } // end namespace
110 //--------------------------------------------------------------------
111     
112 #endif /* end #define CLITKIMAGERESAMPLEGENERICFILTER_H */
113