]> Creatis software - clitk.git/blob - tools/clitkConeBeamProjectImageFilter.h
changes in license header
[clitk.git] / tools / clitkConeBeamProjectImageFilter.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 __clitkConeBeamProjectImageFilter_h
19 #define __clitkConeBeamProjectImageFilter_h
20 #include "clitkImageCommon.h"
21 #include "clitkImageCommon.h"
22 #include "clitkTransformUtilities.h"
23 #include "clitkExtractImageFilter.h"
24 #include "itkRayCastInterpolateImageFunctionWithOrigin.h"
25
26 //ITK include
27 #include "itkLightObject.h"
28 #include "itkResampleImageFilter.h"
29 #include "itkEuler3DTransform.h"
30 #include "itkExtractImageFilter.h"
31 #include "itkFlipImageFilter.h"
32
33 namespace clitk
34 {
35   
36   template <class InputImageType, class OutputImageType >  
37   class ITK_EXPORT ConeBeamProjectImageFilter : public itk::LightObject
38   
39   {
40   public:
41
42     typedef ConeBeamProjectImageFilter     Self;
43     typedef itk::LightObject     Superclass;
44     typedef itk::SmartPointer<Self>            Pointer;
45     typedef itk::SmartPointer<const Self>      ConstPointer;
46    
47     /** Method for creation through the object factory. */
48     itkNewMacro(Self);  
49
50     /** Determine the image dimension. */
51     itkStaticConstMacro(InputImageDimension, unsigned int,
52                         InputImageType::ImageDimension );
53     
54     itkStaticConstMacro(OutputImageDimension, unsigned int,
55                         OutputImageType::ImageDimension );
56
57
58     //========================================================================================
59     //Typedefs 
60     typedef typename InputImageType::Pointer InputImagePointer;
61     typedef typename InputImageType::ConstPointer InputImageConstPointer;
62     typedef typename InputImageType::PixelType InputPixelType;
63     typedef typename InputImageType::SizeType InputSizeType;
64     typedef typename InputImageType::SpacingType InputSpacingType;
65     typedef typename InputImageType::DirectionType InputDirectionType;
66     typedef typename InputImageType::IndexType InputIndexType;
67     typedef typename InputImageType::PointType InputPointType;
68
69     typedef typename OutputImageType::Pointer OutputImagePointer;
70     typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
71     typedef typename OutputImageType::PixelType OutputPixelType;
72     typedef typename OutputImageType::SizeType OutputSizeType;
73     typedef typename OutputImageType::SpacingType OutputSpacingType;
74     typedef typename OutputImageType::DirectionType OutputDirectionType;
75     typedef typename OutputImageType::IndexType OutputIndexType;
76     typedef typename OutputImageType::PointType OutputPointType;
77
78     typedef itk::Image<OutputPixelType, InputImageDimension> InternalImageType;
79
80     //Pipeline
81     typedef itk::Euler3DTransform <double> TransformType;
82     typedef itk::ResampleImageFilter<InputImageType, InternalImageType > ResampleImageFilterType;
83     typedef itk::RayCastInterpolateImageFunctionWithOrigin<InputImageType,double> InterpolatorType;
84     typedef clitk::ExtractImageFilter<InternalImageType, OutputImageType> ExtractImageFilterType;
85     typedef itk::FlipImageFilter<OutputImageType> FlipImageFilterType;
86     typedef itk::Matrix<double,4,4> MatrixType;
87
88     //========================================================================================
89     //Set Methods
90     //========================================================================================
91     // Run-time
92     void SetVerbose(const bool m){m_Verbose=m;}
93     void SetNumberOfThreads(const unsigned int v)
94     {
95       m_NumberOfThreadsIsGiven=true;
96       m_NumberOfThreads=v;
97     }
98
99     void SetInput(const InputImagePointer m) {m_Input=m;} //no reinitialize
100     
101     //=================================================================================
102     //Geometry (reinitialize)
103     void SetIsoCenter( const InputPointType & i )
104     {
105       if( m_IsoCenter!=i)
106         {
107           m_IsoCenter=i;
108           m_IsInitialized=false;
109         }
110     }
111        
112     void SetSourceToScreen(const double& s)
113     {
114       if( m_SourceToScreen!=s)
115         {
116           m_SourceToScreen=s;
117           m_IsInitialized=false;
118         }
119     }
120     
121     void SetSourceToAxis( const double& s)
122     {
123       if( m_SourceToAxis!=s)
124         {
125           m_SourceToAxis=s;
126           m_IsInitialized=false;
127         }
128     }
129     
130     void SetProjectionAngle( const double& s)
131     {
132       if( m_SourceToScreen!=s)
133         {
134           m_ProjectionAngle=s;
135           m_IsInitialized=false;
136         }
137     }
138     
139     void SetRigidTransformMatrix(const MatrixType& m)
140     {
141       if(m_RigidTransformMatrix != m)
142         {
143           m_RigidTransformMatrix=m;
144           m_IsInitialized=false;
145         }
146     }
147        
148     void SetEdgePaddingValue(const OutputPixelType& p)
149     {
150       if (m_EdgePaddingValue!=p)
151         {
152           m_EdgePaddingValue=p;
153           m_IsInitialized=false;
154         }
155     }
156         
157  
158     //========================================================================================
159     //Output image properties
160     /** Get the size of the output image. */
161     void SetOutputSize(const OutputSizeType& p)
162     {
163       if (m_OutputSize!=p)
164         {
165           m_OutputSize=p;
166           m_IsInitialized=false;
167         }
168     }
169      
170     /** Set the output image spacing. */
171     void SetOutputSpacing(const OutputSpacingType& p)
172     {
173       if (m_OutputSpacing!=p)
174         {
175           m_OutputSpacing=p;
176           m_IsInitialized=false;
177         }
178     }
179     
180     /** Set the output image origin. */
181     void SetOutputOrigin(const OutputPointType& p)
182     {
183       if (m_OutputOrigin!=p)
184         {
185           m_OutputOrigin=p;
186           m_IsInitialized=false;
187         }
188     }
189
190     /** Set the panelshift. */
191     void SetPanelShift(double shift)
192     {
193       if (m_PanelShift!=shift)
194         {
195           m_PanelShift=shift;
196           m_IsInitialized=false;
197         }
198     }
199
200     /** Helper method to set the output parameters based on this image */
201     void SetOutputParametersFromImage( const OutputImagePointer image );
202
203     /** Helper method to set the output parameters based on this image */
204     void SetOutputParametersFromImage( const OutputImageConstPointer image );
205
206     //========================================================================================
207     //Update
208     void Initialize(void)throw (itk::ExceptionObject);
209     void Update(void);
210     OutputImagePointer GetOutput(void);
211
212   protected:
213     ConeBeamProjectImageFilter();
214     ~ConeBeamProjectImageFilter() {};
215
216     // Run time  
217     bool m_Verbose;
218     bool m_NumberOfThreadsIsGiven;
219     unsigned int m_NumberOfThreads;
220     bool m_IsInitialized;
221     //std::string m_Mask;
222
223     // Data
224     InputImageConstPointer m_Input;
225     OutputImagePointer m_Output;
226
227     // Geometry
228     InputPointType m_IsoCenter;
229     double m_SourceToScreen;
230     double m_SourceToAxis;
231     double m_ProjectionAngle;
232     double m_PanelShift;
233     MatrixType m_RigidTransformMatrix;
234     OutputPixelType m_EdgePaddingValue;
235
236     // Pipe 
237     TransformType::Pointer m_Transform;
238     typename ResampleImageFilterType::Pointer m_Resampler;
239     typename InterpolatorType::Pointer m_Interpolator;
240     typename ExtractImageFilterType::Pointer m_ExtractImageFilter;
241     typename FlipImageFilterType::Pointer m_FlipImageFilter;
242
243     // Output image info
244     OutputSizeType                m_OutputSize;        // Size of the output image
245     OutputSpacingType             m_OutputSpacing;     // output image spacing
246     OutputPointType               m_OutputOrigin;      // output image origin
247   };
248
249
250 } // end namespace clitk
251 #ifndef ITK_MANUAL_INSTANTIATION
252 #include "clitkConeBeamProjectImageFilter.txx"
253 #endif
254
255 #endif // #define __clitkConeBeamProjectImageFilter_h