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 ===========================================================================**/
18 #ifndef __clitkBackProjectImageFilter_h
19 #define __clitkBackProjectImageFilter_h
20 #include "clitkTransformUtilities.h"
23 #include "itkInterpolateImageFunction.h"
24 #include "itkImageToImageFilter.h"
25 #include "itkTransform.h"
26 #include "itkVector.h"
32 template <class InputImageType, class OutputImageType>
33 class ITK_EXPORT BackProjectImageFilter :
34 public itk::ImageToImageFilter<InputImageType,OutputImageType>
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;
45 /** Method for creation through the object factory. */
48 /** Run-time type information (and related methods). */
49 itkTypeMacro(BackProjectImageFilter, ImageToImageFilter);
51 /** Dimension of the domain space. */
52 itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
53 itkStaticConstMacro(OutputImageDimension, unsigned int, Superclass::OutputImageDimension);
55 //------------------------------------
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;
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;
86 typedef itk::Matrix<double,4,4> MatrixType;
88 //------------------------------------
89 // Projection geometry
90 //-----------------------------------
91 void SetIsoCenter( const OutputPointType& i )
96 m_IsInitialized=false;
101 void SetSourceToScreen(const double &s)
103 if( m_SourceToScreen!=s)
106 m_IsInitialized=false;
111 void SetSourceToAxis( const double& s)
113 if( m_SourceToAxis!=s)
116 m_IsInitialized=false;
121 void SetProjectionAngle(const double& s)
123 if( m_SourceToScreen!=s)
126 m_IsInitialized=false;
131 void SetRigidTransformMatrix(const MatrixType& m)
133 if(m_RigidTransformMatrix != m)
135 m_RigidTransformMatrix=m;
136 m_IsInitialized=false;
141 void SetEdgePaddingValue(const OutputPixelType& p)
143 if (m_EdgePaddingValue!=p)
145 m_EdgePaddingValue=p;
146 m_IsInitialized=false;
151 void SetPanelShift(double x, double y)
156 // itkSetMacro(IsoCenter, OutputPointType);
157 // itkGetConstReferenceMacro(IsoCenter, OutputPointType)
158 // itkSetMacro( SourceToScreen, double );
159 // itkGetMacro( SourceToScreen, double );
160 // itkSetMacro( SourceToAxis, double );
161 // itkGetMacro( SourceToAxis, double );
162 // itkSetMacro(RigidTransformMatrix, itk::Matrix<double,4,4>));
163 // itkGetConstReferenceMacro(RigidTransformMatrix, itk::Matrix<double,4,4>);
164 // void SetRigidTransformMatrix(const itk::Matrix<double,4,4> & m);
165 // itk::Matrix<double,4,4> GetRigidTransformMatrix( void ){return m_RigidTransformMatrix;}
166 // itkSetMacro( EdgePaddingValue, OutputPixelType );
167 // itkGetMacro( EdgePaddingValue, OutputPixelType );
168 // itkSetMacro( ProjectionAngle, double );
169 // itkGetMacro( ProjectionAngle, double );
171 //-----------------------------------
172 //Output image properties
173 //-----------------------------------
174 void SetOutputSize(const OutputSizeType& p)
179 m_IsInitialized=false;
184 /** Set the output image spacing. */
185 void SetOutputSpacing(const OutputSpacingType & p)
187 if (m_OutputSpacing!=p)
190 m_IsInitialized=false;
195 /** Set the output image origin. */
196 void SetOutputOrigin(const OutputPointType& p)
198 if (m_OutputOrigin!=p)
201 m_IsInitialized=false;
206 /** Helper method to set the output parameters based on this image */
207 void SetOutputParametersFromImage( const OutputImagePointer image );
209 /** Helper method to set the output parameters based on this image */
210 void SetOutputParametersFromImage( const OutputImageConstPointer image );
213 void Initialize(void) throw (itk::ExceptionObject);
218 BackProjectImageFilter();
221 ~BackProjectImageFilter(){};
224 void PrintSelf(std::ostream& os, itk::Indent indent) const;
226 // Calculate the projection matrix
227 void CalculateProjectionMatrix(void);
229 // Calculate the coordinate increments
230 void CalculateCoordinateIncrements( void );
232 /** Overrides GenerateInputRequestedRegion() in order to inform
233 * the pipeline execution model of different input requested regions
234 * than the output requested region.
235 * \sa ImageToImageFilter::GenerateInputRequestedRegion() */
236 virtual void GenerateInputRequestedRegion();
238 // Generate Output Information
239 virtual void GenerateOutputInformation (void);
241 // Threaded Generate Data
242 void BeforeThreadedGenerateData(void );
244 // Threaded Generate Data
245 void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId );
248 //------------------------------------------------
250 //------------------------------------------------
251 bool m_IsInitialized;
254 InputImagePointer m_ModifiedInput;
256 // Projection geometry
257 OutputPointType m_IsoCenter;
258 itk::Matrix<double,3,4> m_ProjectionMatrix;
259 HomogeneInputVectorType m_LineInc, m_ColInc, m_PlaneInc;
260 // Homogene2DVectorType m_LineInc, m_ColInc, m_PlaneInc;
261 MatrixType m_RigidTransformMatrix;
262 double m_SourceToScreen;
263 double m_SourceToAxis;
264 OutputPixelType m_EdgePaddingValue;
265 double m_ProjectionAngle;
266 double m_PanelShift[2];
269 OutputSizeType m_OutputSize; // Size of the output image
270 OutputSpacingType m_OutputSpacing; // output image spacing
271 OutputPointType m_OutputOrigin; // output image origin
274 BackProjectImageFilter( const Self& ); //purposely not implemented
275 void operator=( const Self& ); //purposely not implemented
282 #ifndef ITK_MANUAL_INSTANTIATION
283 #include "clitkBackProjectImageFilter.txx"