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 CLITKBACKPROJECTIMAGEGENERICFILTER_TXX
19 #define CLITKBACKPROJECTIMAGEGENERICFILTER_TXX
21 =================================================
22 * @file clitkBackProjectImageGenericFilter.txx
23 * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
26 * @brief Project a 3D image using a cone-beam geometry
28 =================================================*/
34 //================================================================================
35 template <class InputPixelType> void BackProjectImageGenericFilter::UpdateWithPixelType()
38 //---------------------------------
40 //---------------------------------
41 const unsigned int InputImageDimension=2;
42 typedef itk::Image<InputPixelType, InputImageDimension> InputImageType;
43 typedef itk::ImageFileReader<InputImageType> ImageReaderType;
44 typename ImageReaderType::Pointer reader = ImageReaderType::New();
45 reader->SetFileName(m_InputFileName);
47 typename InputImageType::Pointer input = reader->GetOutput();
49 //Define the output type
51 const unsigned int OutputImageDimension=3;
52 typedef float OutputPixelType;
53 typedef itk::Image<OutputPixelType, OutputImageDimension> OutputImageType;
55 //Create the BackProjectImageFilter
56 typedef BackProjectImageFilter<InputImageType, OutputImageType> BackProjectImageFilterType;
57 typename BackProjectImageFilterType::Pointer filter=BackProjectImageFilterType::New();
60 //---------------------------------
61 //Pass all the necessary parameters
62 //---------------------------------
64 filter->SetInput(input);
65 if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg);
67 //Projection parameters
68 OutputImageType::PointType iso;
69 if (m_ArgsInfo.iso_given)
71 for(i=0;i<OutputImageDimension;i++)
72 iso[i]=m_ArgsInfo.iso_arg[i];
73 filter->SetIsoCenter(iso);
75 filter->SetSourceToScreen(m_ArgsInfo.screen_arg);
76 filter->SetSourceToAxis(m_ArgsInfo.axis_arg);
77 filter->SetProjectionAngle(m_ArgsInfo.angle_arg);
78 if (m_ArgsInfo.matrix_given)
80 itk::Matrix<double,4,4> rt =ReadMatrix3D(m_ArgsInfo.matrix_arg);
81 filter->SetRigidTransformMatrix(rt);
83 filter->SetEdgePaddingValue(static_cast<OutputPixelType>(m_ArgsInfo.pad_arg));
86 if (m_ArgsInfo.like_given)
88 typedef itk::ImageFileReader<OutputImageType> ReaderType;
89 ReaderType::Pointer reader2=ReaderType::New();
90 reader2->SetFileName(m_ArgsInfo.like_arg);
93 OutputImageType::Pointer image=reader2->GetOutput();
94 filter->SetOutputParametersFromImage(image);
98 if(m_ArgsInfo.origin_given)
100 OutputImageType::PointType origin;
101 for(i=0;i<OutputImageDimension;i++)
102 origin[i]=m_ArgsInfo.origin_arg[i];
103 filter->SetOutputOrigin(origin);
105 if (m_ArgsInfo.spacing_given)
107 OutputImageType::SpacingType spacing;
108 for(i=0;i<OutputImageDimension;i++)
109 spacing[i]=m_ArgsInfo.spacing_arg[i];
110 filter->SetOutputSpacing(spacing);
112 if (m_ArgsInfo.spacing_given)
114 OutputImageType::SizeType size;
115 for(i=0;i<OutputImageDimension;i++)
116 size[i]=m_ArgsInfo.size_arg[i];
117 filter->SetOutputSize(size);
125 OutputImageType::Pointer output=filter->GetOutput();
128 typedef itk::ImageFileWriter<OutputImageType> OutputWriterType;
129 OutputWriterType::Pointer outputWriter = OutputWriterType::New();
130 outputWriter->SetInput(output);
131 outputWriter->SetFileName(m_ArgsInfo.output_arg);
132 if (m_Verbose)std::cout<<"Writing back projected image..."<<std::endl;
133 outputWriter->Update();
138 #endif //#define CLITKBACKPROJECTIMAGEGENERICFILTER_TXX