// Constructor
ConeBeamProjectImageGenericFilter::ConeBeamProjectImageGenericFilter()
{
-
m_Verbose=false;
m_InputFileName="";
-
-// mIsoCenter.resize(3);
-// for (unsigned int j=0; j < 3; j++) mIsoCenter[j]=128.;
-// mSourceToScreen=1536.;
-// mSourceToAxis=1000.;
-// mProjectionAngle=0.;
-
-// // set the rigid transform matrix to the identity
-// for (unsigned int i=0; i <4; i++)
-// for (unsigned int j=0; j <4; j++)
-// if (i==j)mRigidTransformMatrix[i][j]=1.;
-// else mRigidTransformMatrix[i][j]=0.;
-
-// //Padding value
-// mEdgePaddingValue=0.0;
}
//====================================================================
<< " but I can only work on 3D images.");
}
}
+
+ //================================================================================
+ template <class PixelType> void ConeBeamProjectImageGenericFilter::UpdateWithPixelType()
+ {
+
+ //===================================================================
+ // Read the input image
+ const unsigned int InputImageDimension=3;
+ typedef itk::Image<PixelType, InputImageDimension> InputImageType;
+ typedef itk::ImageFileReader<InputImageType> ImageReaderType;
+ typename ImageReaderType::Pointer reader = ImageReaderType::New();
+ reader->SetFileName(m_InputFileName);
+ reader->Update();
+ typename InputImageType::Pointer input = reader->GetOutput();
+
+ // Define the output type
+ //JV always float?
+ typedef float OutputPixelType;
+ const unsigned int OutputImageDimension=2;
+ typedef itk::Image<OutputPixelType, OutputImageDimension> OutputImageType;
+
+ // Create the ConeBeamProjectImageFilter
+ typedef clitk::ConeBeamProjectImageFilter<InputImageType, OutputImageType> ConeBeamProjectImageFilterType;
+ typename ConeBeamProjectImageFilterType::Pointer filter=ConeBeamProjectImageFilterType::New();
+
+ // Pass all the necessary parameters
+ filter->SetInput(input);
+ filter->SetVerbose(m_Verbose);
+ if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg);
+
+ // Projection parameters
+ typename InputImageType::PointType iso;
+ unsigned int i;
+ if (m_ArgsInfo.iso_given)
+ for(i=0;i<InputImageDimension;i++)
+ {
+ iso[i]=m_ArgsInfo.iso_arg[i];
+ filter->SetIsoCenter(iso);
+ }
+ filter->SetSourceToScreen(m_ArgsInfo.screen_arg);
+ filter->SetSourceToAxis(m_ArgsInfo.axis_arg);
+ filter->SetProjectionAngle(m_ArgsInfo.angle_arg);
+ if (m_ArgsInfo.matrix_given)
+ {
+ itk::Matrix<double,4,4> rt =ReadMatrix3D(m_ArgsInfo.matrix_arg);
+ filter->SetRigidTransformMatrix(rt);
+ }
+ filter->SetEdgePaddingValue(static_cast<OutputPixelType>(m_ArgsInfo.pad_arg));
+
+ // Output image info
+ if (m_ArgsInfo.like_given)
+ {
+ typedef itk::ImageFileReader<OutputImageType> ReaderType;
+ ReaderType::Pointer reader2=ReaderType::New();
+ reader2->SetFileName(m_ArgsInfo.like_arg);
+ reader2->Update();
+
+ OutputImageType::Pointer image=reader2->GetOutput();
+ filter->SetOutputParametersFromImage(image);
+ }
+ else
+ {
+ if (m_ArgsInfo.origin_given)
+ {
+ OutputImageType::PointType origin;
+ for(i=0;i<OutputImageDimension;i++)
+ origin[i]=m_ArgsInfo.origin_arg[i];
+ filter->SetOutputOrigin(origin);
+ }
+ if (m_ArgsInfo.spacing_given)
+ {
+ OutputImageType::SpacingType spacing;
+ for(i=0;i<OutputImageDimension;i++)
+ spacing[i]=m_ArgsInfo.spacing_arg[i];
+ filter->SetOutputSpacing(spacing);
+ }
+ if (m_ArgsInfo.size_given)
+ {
+ OutputImageType::SizeType size;
+ for(i=0;i<OutputImageDimension;i++)
+ size[i]=m_ArgsInfo.size_arg[i];
+ filter->SetOutputSize(size);
+ }
+ }
+
+ //Go
+ filter->Update();
+
+ //Get the output
+ OutputImageType::Pointer output=filter->GetOutput();
+
+ //Write the output
+ typedef itk::ImageFileWriter<OutputImageType> OutputWriterType;
+ OutputWriterType::Pointer outputWriter = OutputWriterType::New();
+ outputWriter->SetInput(output);
+ outputWriter->SetFileName(m_ArgsInfo.output_arg);
+ if (m_Verbose)std::cout<<"Writing projected image..."<<std::endl;
+ outputWriter->Update();
+ }
//====================================================================
m_Verbose=m_ArgsInfo.verbose_flag;
}
- // void SetVerbose(const bool v){mVerbose=v;}
- // void SetInput(const std::string i) { mInput = i; }
- // void SetOutput(const std::string o) { mOutput = o; }
- // void SetMask(const std::string m) {mMask = m;}
- // void SetIsoCenter(const std::vector<double> i)
- // {
- // mIsoCenter.resize(3);
- // for (unsigned int j=0; j < 3; j++) mIsoCenter[j]=i[j];
- // }
- // void SetSourceToScreen(const double s) {mSourceToScreen = s;}
- // void SetSourceToAxis(const double s) {mSourceToAxis = s;}
- // void SetProjectionAngle(const double a) {mProjectionAngle = a;}
- // void SetRigidTransformMatrix(const itk::Matrix<double,4,4> m) {mRigidTransformMatrix=m;}
- // void SetEdgePaddingValue(const double m) {mEdgePaddingValue=m;}
//====================================================================
// Update
bool m_Verbose;
std::string m_InputFileName;
args_info_clitkConeBeamProjectImage m_ArgsInfo;
- // std::string mOutput;
- // std::string mMask;
- // std::vector<double> mIsoCenter;
- // double mSourceToScreen;
- // double mSourceToAxis;
- // double mProjectionAngle;
- // itk::Matrix<double,4,4> mRigidTransformMatrix;
- // double mEdgePaddingValue;
};
} // end namespace clitk
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkConeBeamProjectImageGenericFilter.txx"
-#endif
#endif //#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER__H
+++ /dev/null
-/*=========================================================================
- Program: vv http://www.creatis.insa-lyon.fr/rio/vv
-
- Authors belong to:
- - University of LYON http://www.universite-lyon.fr/
- - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr
- - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr
-
- This software is distributed WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the copyright notices for more information.
-
- It is distributed under dual licence
-
- - BSD See included LICENSE.txt file
- - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-======================================================================-====*/
-#ifndef CLITKCONEBEAMPROJECTIMAGEGENERICFILTER_TXX
-#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER_TXX
-/**
- =================================================
- * @file clitkConeBeamProjectImageGenericFilter.txx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date 30 April 2008
- *
- * @brief Project a 3D image using a cone-beam geometry
- *
- =================================================*/
-
-
-namespace clitk
-{
-
- //================================================================================
- template <class PixelType> void ConeBeamProjectImageGenericFilter::UpdateWithPixelType()
- {
-
- //===================================================================
- // Read the input image
- const unsigned int InputImageDimension=3;
- typedef itk::Image<PixelType, InputImageDimension> InputImageType;
- typedef itk::ImageFileReader<InputImageType> ImageReaderType;
- typename ImageReaderType::Pointer reader = ImageReaderType::New();
- reader->SetFileName(m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input = reader->GetOutput();
-
- // Define the output type
- //JV always float?
- typedef float OutputPixelType;
- const unsigned int OutputImageDimension=2;
- typedef itk::Image<OutputPixelType, OutputImageDimension> OutputImageType;
-
- // Create the ConeBeamProjectImageFilter
- typedef clitk::ConeBeamProjectImageFilter<InputImageType, OutputImageType> ConeBeamProjectImageFilterType;
- typename ConeBeamProjectImageFilterType::Pointer filter=ConeBeamProjectImageFilterType::New();
-
- // Pass all the necessary parameters
- filter->SetInput(input);
- filter->SetVerbose(m_Verbose);
- if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg);
-
- // Projection parameters
- typename InputImageType::PointType iso;
- unsigned int i;
- if (m_ArgsInfo.iso_given)
- for(i=0;i<InputImageDimension;i++)
- {
- iso[i]=m_ArgsInfo.iso_arg[i];
- filter->SetIsoCenter(iso);
- }
- filter->SetSourceToScreen(m_ArgsInfo.screen_arg);
- filter->SetSourceToAxis(m_ArgsInfo.axis_arg);
- filter->SetProjectionAngle(m_ArgsInfo.angle_arg);
- if (m_ArgsInfo.matrix_given)
- {
- itk::Matrix<double,4,4> rt =ReadMatrix3D(m_ArgsInfo.matrix_arg);
- filter->SetRigidTransformMatrix(rt);
- }
- filter->SetEdgePaddingValue(static_cast<OutputPixelType>(m_ArgsInfo.pad_arg));
-
- // Output image info
- if (m_ArgsInfo.like_given)
- {
- typedef itk::ImageFileReader<OutputImageType> ReaderType;
- ReaderType::Pointer reader2=ReaderType::New();
- reader2->SetFileName(m_ArgsInfo.like_arg);
- reader2->Update();
-
- OutputImageType::Pointer image=reader2->GetOutput();
- filter->SetOutputParametersFromImage(image);
- }
- else
- {
- if (m_ArgsInfo.origin_given)
- {
- OutputImageType::PointType origin;
- for(i=0;i<OutputImageDimension;i++)
- origin[i]=m_ArgsInfo.origin_arg[i];
- filter->SetOutputOrigin(origin);
- }
- if (m_ArgsInfo.spacing_given)
- {
- OutputImageType::SpacingType spacing;
- for(i=0;i<OutputImageDimension;i++)
- spacing[i]=m_ArgsInfo.spacing_arg[i];
- filter->SetOutputSpacing(spacing);
- }
- if (m_ArgsInfo.size_given)
- {
- OutputImageType::SizeType size;
- for(i=0;i<OutputImageDimension;i++)
- size[i]=m_ArgsInfo.size_arg[i];
- filter->SetOutputSize(size);
- }
- }
-
- //Go
- filter->Update();
-
- //Get the output
- OutputImageType::Pointer output=filter->GetOutput();
-
- //Write the output
- typedef itk::ImageFileWriter<OutputImageType> OutputWriterType;
- OutputWriterType::Pointer outputWriter = OutputWriterType::New();
- outputWriter->SetInput(output);
- outputWriter->SetFileName(m_ArgsInfo.output_arg);
- if (m_Verbose)std::cout<<"Writing projected image..."<<std::endl;
- outputWriter->Update();
- }
-
-}
-
-#endif //#define CLITKGENERICIMAGEFILTER