1 /*=========================================================================
2 Program: vv http://www.creatis.insa-lyon.fr/rio/vv
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
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.
13 It is distributed under dual licence
15 - BSD See included LICENSE.txt file
16 - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
17 ===========================================================================**/
19 #ifndef CLITKRESAMPLEIMAGEWITHOPTIONSFILTER_H
20 #define CLITKRESAMPLEIMAGEWITHOPTIONSFILTER_H
22 #include "itkImageToImageFilter.h"
23 #include "itkAffineTransform.h"
25 #include "clitkCommon.h"
29 //--------------------------------------------------------------------
31 Image resampling with several interpolations and Gaussian filtering included.
33 //--------------------------------------------------------------------
34 template <class InputImageType, class OutputImageType=InputImageType>
35 class ITK_EXPORT ResampleImageWithOptionsFilter:
36 public itk::ImageToImageFilter<InputImageType, OutputImageType> {
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;
45 /** Method for creation through the object factory. */
48 /** Run-time type information (and related methods). */
49 itkTypeMacro(ResampleImageWithOptionsFilter, ImageToImageFilter);
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;
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;
68 typedef itk::AffineTransform<double, InputImageType::ImageDimension> TransformType;
69 typedef typename InputImageType::SpacingType GaussianSigmaType;
71 /** Interpolation types */
78 } InterpolationTypeEnumeration;
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>));
88 /** Input : image to resample */
89 void SetInput(const InputImageType * image) ITK_OVERRIDE;
91 /** ImageDimension constants */
92 itkStaticConstMacro(ImageDimension, unsigned int, InputImageType::ImageDimension);
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);
125 ResampleImageWithOptionsFilter();
126 virtual ~ResampleImageWithOptionsFilter() {}
128 bool m_LastDimensionIsTime;
129 double m_OutputIsoSpacing;
130 InterpolationTypeEnumeration m_InterpolationType;
131 bool m_GaussianFilteringEnabled;
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;
144 virtual void GenerateInputRequestedRegion() ITK_OVERRIDE;
145 virtual void GenerateOutputInformation() ITK_OVERRIDE;
146 virtual void GenerateData() ITK_OVERRIDE;
149 ResampleImageWithOptionsFilter(const Self&); //purposely not implemented
150 void operator=(const Self&); //purposely not implemented
153 //--------------------------------------------------------------------
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);
161 } // end namespace clitk
162 //--------------------------------------------------------------------
164 #ifndef ITK_MANUAL_INSTANTIATION
165 #include "clitkResampleImageWithOptionsFilter.txx"