]> Creatis software - clitk.git/blob - itk/clitkBackProjectImageFilter.h
changes in license header
[clitk.git] / itk / clitkBackProjectImageFilter.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 __clitkBackProjectImageFilter_h
19 #define __clitkBackProjectImageFilter_h
20 #include "clitkTransformUtilities.h"
21
22 //itk include
23 #include "itkInterpolateImageFunction.h"                                  
24 #include "itkImageToImageFilter.h"                                  
25 #include "itkTransform.h"
26 #include "itkVector.h"
27
28
29 namespace clitk
30 {
31
32   template <class InputImageType, class OutputImageType>
33   class ITK_EXPORT BackProjectImageFilter : 
34     public itk::ImageToImageFilter<InputImageType,OutputImageType> 
35   {
36   public:
37     //------------------------------------
38     // Standard itk typedefs
39     //-----------------------------------
40     typedef BackProjectImageFilter                                  Self;
41     typedef itk::ImageToImageFilter<InputImageType,OutputImageType> Superclass;
42     typedef itk::SmartPointer<Self>                                 Pointer;
43     typedef itk::SmartPointer<const Self>                           ConstPointer;
44
45     /** Method for creation through the object factory. */
46     itkNewMacro(Self); 
47
48     /** Run-time type information (and related methods). */
49     itkTypeMacro(BackProjectImageFilter, ImageToImageFilter); 
50
51     /** Dimension of the domain space. */
52     itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
53     itkStaticConstMacro(OutputImageDimension, unsigned int, Superclass::OutputImageDimension);
54
55     //------------------------------------
56     // Typedefs
57     //------------------------------------
58     typedef typename InputImageType::Pointer InputImagePointer;
59     typedef typename InputImageType::ConstPointer InputImageConstPointer;
60     typedef typename InputImageType::PixelType InputPixelType;
61     typedef typename InputImageType::SizeType InputSizeType;
62     typedef typename InputImageType::SpacingType InputSpacingType;
63     typedef typename InputImageType::DirectionType InputDirectionType;
64     typedef typename InputImageType::IndexType InputIndexType;
65     typedef typename InputImageType::PointType InputPointType;
66     typedef typename itk::ContinuousIndex<double,InputImageDimension> ContinuousInputIndexType;
67     typedef typename InputImageType::RegionType InputImageRegionType;
68     typedef itk::Vector<double,InputImageDimension+1> HomogeneInputVectorType;
69     typedef itk::Vector<double,InputImageDimension> Homogene2DVectorType;
70     typedef itk::Point<double,InputImageDimension+1> HomogeneInputPointType;
71     typedef itk::Point<double,InputImageDimension> Homogene2DPointType;
72
73     typedef typename OutputImageType::Pointer OutputImagePointer;
74     typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
75     typedef typename OutputImageType::PixelType OutputPixelType;
76     typedef typename OutputImageType::SizeType OutputSizeType;
77     typedef typename OutputImageType::SpacingType OutputSpacingType;
78     typedef typename OutputImageType::DirectionType OutputDirectionType;
79     typedef typename OutputImageType::IndexType OutputIndexType;
80     typedef typename OutputImageType::PointType OutputPointType;
81     typedef typename itk::ContinuousIndex<double,OutputImageDimension> ContinuousOutputIndexType;
82     typedef typename OutputImageType::RegionType OutputImageRegionType;
83     typedef itk::Vector<double,OutputImageDimension+1> HomogeneOutputVectorType;
84     typedef itk::Point<double,OutputImageDimension+1> HomogeneOutputPointType;
85
86     typedef itk::Matrix<double,4,4> MatrixType;
87   
88     //------------------------------------
89     // Projection geometry
90     //-----------------------------------
91     void SetIsoCenter( const OutputPointType& i )
92     {
93       if( m_IsoCenter!=i)
94         {
95           m_IsoCenter=i;
96           m_IsInitialized=false;
97           this->Modified();
98         }
99     }
100        
101     void SetSourceToScreen(const double &s)
102     {
103       if( m_SourceToScreen!=s)
104         {
105           m_SourceToScreen=s;
106           m_IsInitialized=false;
107           this->Modified();
108         }
109     }
110     
111     void SetSourceToAxis( const double& s)
112     {
113       if( m_SourceToAxis!=s)
114         {
115           m_SourceToAxis=s;
116           m_IsInitialized=false;
117           this->Modified();
118         }
119     }
120     
121     void SetProjectionAngle(const double& s)
122     {
123       if( m_SourceToScreen!=s)
124         {
125           m_ProjectionAngle=s;
126           m_IsInitialized=false;
127           this->Modified();
128         }
129     }
130     
131     void SetRigidTransformMatrix(const MatrixType& m)
132     {
133       if(m_RigidTransformMatrix != m)
134         {
135           m_RigidTransformMatrix=m;
136           m_IsInitialized=false;
137           this->Modified();
138         }
139     }
140        
141     void SetEdgePaddingValue(const OutputPixelType& p)
142     {
143       if (m_EdgePaddingValue!=p)
144         {
145           m_EdgePaddingValue=p;
146           m_IsInitialized=false;
147           this->Modified();
148         }
149     }
150
151     //     itkSetMacro(IsoCenter, OutputPointType);
152     //     itkGetConstReferenceMacro(IsoCenter, OutputPointType)
153     //     itkSetMacro( SourceToScreen, double );
154     //     itkGetMacro( SourceToScreen, double );
155     //     itkSetMacro( SourceToAxis, double );
156     //     itkGetMacro( SourceToAxis, double );
157     //     itkSetMacro(RigidTransformMatrix, itk::Matrix<double,4,4>));
158     //     itkGetConstReferenceMacro(RigidTransformMatrix, itk::Matrix<double,4,4>);
159     //     void SetRigidTransformMatrix(const  itk::Matrix<double,4,4> & m);
160     //     itk::Matrix<double,4,4> GetRigidTransformMatrix( void ){return m_RigidTransformMatrix;}
161     //     itkSetMacro( EdgePaddingValue, OutputPixelType );
162     //     itkGetMacro( EdgePaddingValue, OutputPixelType );
163     //     itkSetMacro( ProjectionAngle, double );
164     //     itkGetMacro( ProjectionAngle, double );
165   
166     //-----------------------------------
167     //Output image properties
168     //-----------------------------------
169     void SetOutputSize(const OutputSizeType& p)
170     {
171       if (m_OutputSize!=p)
172         {
173           m_OutputSize=p;
174           m_IsInitialized=false;
175           this->Modified();
176         }
177     }
178      
179     /** Set the output image spacing. */
180     void SetOutputSpacing(const OutputSpacingType & p)
181     {
182       if (m_OutputSpacing!=p)
183         {
184           m_OutputSpacing=p;
185           m_IsInitialized=false;
186           this->Modified();
187         }
188     }
189     
190     /** Set the output image origin. */
191     void SetOutputOrigin(const OutputPointType& p)
192     {
193       if (m_OutputOrigin!=p)
194         {
195           m_OutputOrigin=p;
196           m_IsInitialized=false;
197           this->Modified();
198         }
199     }
200
201     /** Helper method to set the output parameters based on this image */
202     void SetOutputParametersFromImage( const OutputImagePointer image );
203
204     /** Helper method to set the output parameters based on this image */
205     void SetOutputParametersFromImage( const OutputImageConstPointer  image );
206
207
208     void Initialize(void) throw (itk::ExceptionObject);
209
210   protected:
211
212     // Constructor
213     BackProjectImageFilter();
214
215     // Destructor
216     ~BackProjectImageFilter(){};
217
218     // Print the object
219     void PrintSelf(std::ostream& os, itk::Indent indent) const;
220
221     // Calculate the projection matrix
222     void CalculateProjectionMatrix(void);
223
224     // Calculate the coordinate increments
225     void CalculateCoordinateIncrements( void );
226  
227     /** Overrides GenerateInputRequestedRegion() in order to inform
228      * the pipeline execution model of different input requested regions
229      * than the output requested region.
230      * \sa ImageToImageFilter::GenerateInputRequestedRegion() */
231     virtual void GenerateInputRequestedRegion();
232     
233     // Generate Output Information
234     virtual void GenerateOutputInformation (void);
235
236     // Threaded Generate Data
237     void BeforeThreadedGenerateData(void );
238   
239     // Threaded Generate Data
240     void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId );
241
242  
243     //------------------------------------------------
244     //Member data
245     //------------------------------------------------
246     bool m_IsInitialized;
247     
248     // Input
249     InputImagePointer m_ModifiedInput;
250
251     // Projection geometry
252     OutputPointType m_IsoCenter;
253     itk::Matrix<double,3,4>  m_ProjectionMatrix;
254     HomogeneInputVectorType m_LineInc, m_ColInc, m_PlaneInc;
255     // Homogene2DVectorType m_LineInc, m_ColInc, m_PlaneInc;
256     MatrixType  m_RigidTransformMatrix;
257     double  m_SourceToScreen;
258     double  m_SourceToAxis;
259     OutputPixelType m_EdgePaddingValue;
260     double m_ProjectionAngle;
261
262     // Output image info
263     OutputSizeType                m_OutputSize;        // Size of the output image
264     OutputSpacingType             m_OutputSpacing;     // output image spacing
265     OutputPointType               m_OutputOrigin;      // output image origin
266    
267   private:
268     BackProjectImageFilter( const Self& ); //purposely not implemented
269     void operator=( const Self& ); //purposely not implemented
270
271
272   };
273
274 } // namespace clitk
275
276 #ifndef ITK_MANUAL_INSTANTIATION
277 #include "clitkBackProjectImageFilter.txx"
278 #endif
279
280 #endif