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) {
66 #if ITK_VERSION_MAJOR <= 4
67 filter->SetNumberOfThreads(m_ArgsInfo.threads_arg);
69 filter->SetNumberOfWorkUnits(m_ArgsInfo.threads_arg);
73 //Projection parameters
74 OutputImageType::PointType iso;
75 if (m_ArgsInfo.iso_given)
77 for(i=0;i<OutputImageDimension;i++)
78 iso[i]=m_ArgsInfo.iso_arg[i];
79 filter->SetIsoCenter(iso);
81 if (m_ArgsInfo.panel_shift_given)
82 filter->SetPanelShift(m_ArgsInfo.panel_shift_arg[0], m_ArgsInfo.panel_shift_arg[1]);
83 filter->SetSourceToScreen(m_ArgsInfo.screen_arg);
84 filter->SetSourceToAxis(m_ArgsInfo.axis_arg);
85 filter->SetProjectionAngle(m_ArgsInfo.angle_arg);
86 if (m_ArgsInfo.matrix_given)
88 itk::Matrix<double,4,4> rt =ReadMatrix3D(m_ArgsInfo.matrix_arg);
89 filter->SetRigidTransformMatrix(rt);
91 filter->SetEdgePaddingValue(static_cast<OutputPixelType>(m_ArgsInfo.pad_arg));
94 if (m_ArgsInfo.like_given)
96 typedef itk::ImageFileReader<OutputImageType> ReaderType;
97 ReaderType::Pointer reader2=ReaderType::New();
98 reader2->SetFileName(m_ArgsInfo.like_arg);
101 OutputImageType::Pointer image=reader2->GetOutput();
102 filter->SetOutputParametersFromImage(image);
106 if(m_ArgsInfo.origin_given)
108 OutputImageType::PointType origin;
109 for(i=0;i<OutputImageDimension;i++)
110 origin[i]=m_ArgsInfo.origin_arg[i];
111 filter->SetOutputOrigin(origin);
113 if (m_ArgsInfo.spacing_given)
115 OutputImageType::SpacingType spacing;
116 for(i=0;i<OutputImageDimension;i++)
117 spacing[i]=m_ArgsInfo.spacing_arg[i];
118 filter->SetOutputSpacing(spacing);
120 if (m_ArgsInfo.spacing_given)
122 OutputImageType::SizeType size;
123 for(i=0;i<OutputImageDimension;i++)
124 size[i]=m_ArgsInfo.size_arg[i];
125 filter->SetOutputSize(size);
133 OutputImageType::Pointer output=filter->GetOutput();
136 typedef itk::ImageFileWriter<OutputImageType> OutputWriterType;
137 OutputWriterType::Pointer outputWriter = OutputWriterType::New();
138 outputWriter->SetInput(output);
139 outputWriter->SetFileName(m_ArgsInfo.output_arg);
140 if (m_Verbose)std::cout<<"Writing back projected image..."<<std::endl;
141 outputWriter->Update();
146 #endif //#define CLITKBACKPROJECTIMAGEGENERICFILTER_TXX