]> Creatis software - clitk.git/blob - tools/clitkConeBeamProjectImageFilter.h
GateAsciiImageIO is now cross-platform using itksys::RegularExpression
[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 x, double y)
192     {
193       if (m_PanelShift[0] != x)
194         {
195           m_PanelShift[0] = x;
196           m_IsInitialized=false;
197         }
198       if (m_PanelShift[1] != y)
199         {
200           m_PanelShift[1] = y;
201           m_IsInitialized=false;
202         }
203     }
204
205     /** Helper method to set the output parameters based on this image */
206     void SetOutputParametersFromImage( const OutputImagePointer image );
207
208     /** Helper method to set the output parameters based on this image */
209     void SetOutputParametersFromImage( const OutputImageConstPointer image );
210
211     //========================================================================================
212     //Update
213     void Initialize(void)throw (itk::ExceptionObject);
214     void Update(void);
215     OutputImagePointer GetOutput(void);
216
217   protected:
218     ConeBeamProjectImageFilter();
219     ~ConeBeamProjectImageFilter() {};
220
221     // Run time  
222     bool m_Verbose;
223     bool m_NumberOfThreadsIsGiven;
224     unsigned int m_NumberOfThreads;
225     bool m_IsInitialized;
226     //std::string m_Mask;
227
228     // Data
229     InputImageConstPointer m_Input;
230     OutputImagePointer m_Output;
231
232     // Geometry
233     InputPointType m_IsoCenter;
234     double m_SourceToScreen;
235     double m_SourceToAxis;
236     double m_ProjectionAngle;
237     double m_PanelShift[2];
238     MatrixType m_RigidTransformMatrix;
239     OutputPixelType m_EdgePaddingValue;
240
241     // Pipe 
242     TransformType::Pointer m_Transform;
243     typename ResampleImageFilterType::Pointer m_Resampler;
244     typename InterpolatorType::Pointer m_Interpolator;
245     typename ExtractImageFilterType::Pointer m_ExtractImageFilter;
246     typename FlipImageFilterType::Pointer m_FlipImageFilter;
247
248     // Output image info
249     OutputSizeType                m_OutputSize;        // Size of the output image
250     OutputSpacingType             m_OutputSpacing;     // output image spacing
251     OutputPointType               m_OutputOrigin;      // output image origin
252   };
253
254
255 } // end namespace clitk
256 #ifndef ITK_MANUAL_INSTANTIATION
257 #include "clitkConeBeamProjectImageFilter.txx"
258 #endif
259
260 #endif // #define __clitkConeBeamProjectImageFilter_h