+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkBSplinePyramid.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkBSplinePyramid_ggo.h"
-#include "clitkIO.h"
-#include "clitkBSplinePyramidGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkBSplinePyramid, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::BSplinePyramidGenericFilter::Pointer genericFilter=clitk::BSplinePyramidGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkBSplinePyramid.ggo
-package "clitkBSplinePyramid"
-version "1.0"
-purpose "Down (or Up) sample with a factor 2 using Bspline pyramids. BSplineDownsampleImageFilter is BUGGED! See the ITK post of jvdmb@hotmail.com."
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-
-
-option "up" u "Upsample instead of downsample" flag off
-option "resamplerType" t "The type of B-spline resampler used: 0=resampler, 1=L2, 2=centered, 3=L2 centered" int no default="0"
-option "splineOrder" - "Spline order" int no default="3"
+++ /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://www.centreleonberard.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 clitkBSplinePyramidGenericFilter_cxx
-#define clitkBSplinePyramidGenericFilter_cxx
-
-/* =================================================
- * @file clitkBSplinePyramidGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkBSplinePyramidGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- BSplinePyramidGenericFilter::BSplinePyramidGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void BSplinePyramidGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension, Components;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
- else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
- else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
- else
- {
- std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkBSplinePyramidGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkBSplinePyramidGenericFilter_h
-#define clitkBSplinePyramidGenericFilter_h
-
-/* =================================================
- * @file clitkBSplinePyramidGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkBSplinePyramid_ggo.h"
-#include "clitkVectorImageToImageFilter.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkBSplineDownsampleImageFilter.h"
-#include "itkBSplineUpsampleImageFilter.h"
-#include "itkCompose3DVectorImageFilter.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT BSplinePyramidGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef BSplinePyramidGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( BSplinePyramidGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkBSplinePyramid & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- BSplinePyramidGenericFilter();
- ~BSplinePyramidGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndVectorType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkBSplinePyramid m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkBSplinePyramidGenericFilter.txx"
-#endif
-
-#endif // #define clitkBSplinePyramidGenericFilter_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://www.centreleonberard.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 clitkBSplinePyramidGenericFilter_txx
-#define clitkBSplinePyramidGenericFilter_txx
-
-/* =================================================
- * @file clitkBSplinePyramidGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- BSplinePyramidGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
-
- if (Components==1)
- {
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
- else if (Components==3)
- {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
- UpdateWithDimAndVectorType<Dimension, itk::Vector<float, 3> >();
- }
- else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
-
- }
-
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- BSplinePyramidGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Resampler Types
- typedef itk::BSplineResampleImageFilterBase<InputImageType, InputImageType> ResamplerType;
- typedef itk::BSplineCenteredResampleImageFilterBase<InputImageType, InputImageType> CenteredResamplerType;
- typedef itk::BSplineL2ResampleImageFilterBase<InputImageType, InputImageType> L2ResamplerType;
- typedef itk::BSplineCenteredL2ResampleImageFilterBase<InputImageType, InputImageType> CenteredL2ResamplerType;
-
- // Filter
- typedef itk::ImageToImageFilter< InputImageType, InputImageType > ImageToImageFilterType;
- typename ImageToImageFilterType::Pointer filter;
-
- if (!m_ArgsInfo.up_flag)
- {
- switch (m_ArgsInfo.resamplerType_arg)
- {
-
- // Resampler
- case 0: {
- typename itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, ResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with standard Resampler"<<std::endl;
- break;
- }
-
- //CenteredResamplerType
- case 1: {
- typename itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, CenteredResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, CenteredResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with centered Resampler"<<std::endl;
- break;
- }
-
- //L2ResamplerType
- case 2:
- {
- typename itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, L2ResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InputImageType,InputImageType,L2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 Resampler"<<std::endl;
- break;
- }
-
- //Centered L2ResamplerType
- case 3:
- {
- typename itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, CenteredL2ResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InputImageType,InputImageType,CenteredL2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 centered Resampler"<<std::endl;
- break;
- }
-
- }
- }
- else
- {
- switch (m_ArgsInfo.resamplerType_arg)
- {
-
- // Resampler
- case 0: {
- typename itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, ResamplerType >::Pointer df
- = itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline upsample image filter with standard Resampler"<<std::endl;
- break;
- }
-
- //CenteredResamplerType
- case 1: {
- typename itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, CenteredResamplerType >::Pointer df
- = itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, CenteredResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline upsample image filter with centered Resampler"<<std::endl;
- break;
- }
-
- //L2ResamplerType
- case 2:
- {
- typename itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, L2ResamplerType >::Pointer df
- = itk::BSplineUpsampleImageFilter< InputImageType,InputImageType,L2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline upsample image filter with L2 Resampler"<<std::endl;
- break;
- }
-
- //Centered L2ResamplerType
- case 3:
- {
- typename itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, CenteredL2ResamplerType >::Pointer df
- = itk::BSplineUpsampleImageFilter< InputImageType,InputImageType,CenteredL2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline upsample image filter with L2 centered Resampler"<<std::endl;
- break;
- }
-
- }
- }
-
-
- // Update
- filter->SetInput(input);
- filter->Update();
- typename OutputImageType::Pointer output=filter->GetOutput();
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class VectorType>
- void
- BSplinePyramidGenericFilter::UpdateWithDimAndVectorType()
- {
-
- // ImageTypes
- typedef typename VectorType::ValueType PixelType;
- typedef itk::Image<VectorType, Dimension> VectorInputImageType;
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
- typedef itk::Image<VectorType, Dimension> VectorOutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<VectorInputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename VectorInputImageType::Pointer vectorInput= reader->GetOutput();
-
- // Process components separetely and gather afterwards
- std::vector<typename OutputImageType::Pointer> components;
-
- for (unsigned int i=0; i<3;i++)
- {
- // Extract component
- typedef clitk::VectorImageToImageFilter<VectorInputImageType, OutputImageType> FilterType;
- typename FilterType::Pointer dfilter=FilterType::New();
- dfilter->SetInput(vectorInput);
- dfilter->SetComponentIndex(i);
- dfilter->Update();
- typename InputImageType::Pointer input=dfilter->GetOutput();
-
- //============================================================================================
- // Resampler Types
- typedef itk::BSplineResampleImageFilterBase<InputImageType, InputImageType> ResamplerType;
- typedef itk::BSplineCenteredResampleImageFilterBase<InputImageType, InputImageType> CenteredResamplerType;
- typedef itk::BSplineL2ResampleImageFilterBase<InputImageType, InputImageType> L2ResamplerType;
- typedef itk::BSplineCenteredL2ResampleImageFilterBase<InputImageType, InputImageType> CenteredL2ResamplerType;
-
- // Filter
- typedef itk::ImageToImageFilter< InputImageType, InputImageType > ImageToImageFilterType;
- typename ImageToImageFilterType::Pointer filter;
-
- if (!m_ArgsInfo.up_flag)
- {
- switch (m_ArgsInfo.resamplerType_arg)
- {
-
- // Resampler
- case 0: {
- typename itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, ResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with standard Resampler"<<std::endl;
- break;
- }
-
- //CenteredResamplerType
- case 1: {
- typename itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, CenteredResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, CenteredResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with centered Resampler"<<std::endl;
- break;
- }
-
- //L2ResamplerType
- case 2:
- {
- typename itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, L2ResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InputImageType,InputImageType,L2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 Resampler"<<std::endl;
- break;
- }
-
- //Centered L2ResamplerType
- case 3:
- {
- typename itk::BSplineDownsampleImageFilter< InputImageType,InputImageType, CenteredL2ResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InputImageType,InputImageType,CenteredL2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 centered Resampler"<<std::endl;
- break;
- }
-
- }
- }
- else
- {
- switch (m_ArgsInfo.resamplerType_arg)
- {
-
- // Resampler
- case 0: {
- typename itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, ResamplerType >::Pointer df
- = itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline upsample image filter with standard Resampler"<<std::endl;
- break;
- }
-
- //CenteredResamplerType
- case 1: {
- typename itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, CenteredResamplerType >::Pointer df
- = itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, CenteredResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline upsample image filter with centered Resampler"<<std::endl;
- break;
- }
-
- //L2ResamplerType
- case 2:
- {
- typename itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, L2ResamplerType >::Pointer df
- = itk::BSplineUpsampleImageFilter< InputImageType,InputImageType,L2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline upsample image filter with L2 Resampler"<<std::endl;
- break;
- }
-
- //Centered L2ResamplerType
- case 3:
- {
- typename itk::BSplineUpsampleImageFilter< InputImageType,InputImageType, CenteredL2ResamplerType >::Pointer df
- = itk::BSplineUpsampleImageFilter< InputImageType,InputImageType,CenteredL2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline upsample image filter with L2 centered Resampler"<<std::endl;
- break;
- }
-
- }
- }
-
- // Update
- filter->SetInput(input);
- filter->Update();
- typename OutputImageType::Pointer output=filter->GetOutput();
-
- //===============================================================================
- // keep component
- components.push_back(output);
- }
-
- // Join
- typedef itk::Compose3DVectorImageFilter<InputImageType,VectorOutputImageType> ComposeFilterType;
- typename ComposeFilterType::Pointer composeFilter=ComposeFilterType::New();
- for (unsigned int i=0; i<3;i++)
- composeFilter->SetInput(i,components[i]);
- composeFilter->Update();
- typename VectorOutputImageType::Pointer vectorOutput = composeFilter->GetOutput();
-
-
- // Output
- typedef itk::ImageFileWriter<VectorOutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(vectorOutput);
- writer->Update();
-
- }
-
-}//end clitk
-
-#endif //#define clitkBSplinePyramidGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkConvertPointList.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkConvertPointList_ggo.h"
-#include "clitkIO.h"
-#include "clitkImageCommon.h"
-#include "clitkList.h"
-#include "clitkLists.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkConvertPointList, args_info);
- CLITK_INIT;
-
- // List
- typedef itk::Point<double, 3> PointType;
- typedef clitk::List<PointType> ListType;
- typedef clitk::Lists<PointType> ListsType;
- ListType refList;
- ListsType targetLists;
-
- // Image
- typedef itk::Image<signed short, 3> ImageType;
- ImageType::Pointer referenceImage=clitk::readImage<ImageType>(args_info.refIm_arg, args_info.verbose_flag);
-
- // Filenames
- std::vector< std::string> fileNames;
- for(unsigned int i=0; i< args_info.lists_given; i++)
- {
- fileNames.push_back(args_info.lists_arg[i]);
- if (args_info.verbose_flag) std::cout<<"Adding input point list "<<fileNames[i]<<std::endl;
- }
-
- // Read and convert
- targetLists.ReadAndConvertPointPairs(fileNames, refList, referenceImage, args_info.verbose_flag );
-
- // Write
- if (args_info.ref_given) refList.Write(args_info.ref_arg, args_info.verbose_flag);
- if (args_info.targets_given == args_info.lists_given)
- {
- // output filenames
- std::vector<std::string> oFileNames;
- for(unsigned int i=0; i< args_info.targets_given; i++)
- oFileNames.push_back(args_info.targets_arg[i]);
- targetLists.Write(oFileNames, args_info.verbose_flag);
- }
-
- return EXIT_SUCCESS;
-
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkConvertPointList.ggo
-package "clitkConvertPointList"
-version "1.0"
-purpose "Convert IX point pair lists (generated using the software described in Murphy2008,MICCAI) to a vv point pair lists"
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-section "I/O"
-
-option "lists" l "Input IX lists filenames" string yes multiple
-option "refIm" i "Input reference image filename" string yes
-option "ref" r "Output reference list filename" string yes
-option "targets" c "Output target lists filenames" string yes multiple
-
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkMultiResolutionPyramid.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkMultiResolutionPyramid_ggo.h"
-#include "clitkIO.h"
-#include "clitkMultiResolutionPyramidGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkMultiResolutionPyramid, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::MultiResolutionPyramidGenericFilter::Pointer genericFilter=clitk::MultiResolutionPyramidGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkMultiResolutionPyramid.ggo
-package "clitkMultiResolutionPyramid"
-version "1.0"
-purpose "Compute the multi-resolution (MR) image pyramid. The conventional filter will also modify the image at the original resolution, the recursive not. The spatio-temporal filters leave the last dimension untouched."
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-section "IO"
-option "input" i "Input image filename" string yes
-option "output" o "Output image (level) filenames" string yes multiple
-
-section "Pyramid"
-option "type" t "0=MR, 1= recursive MR, 2=spatio-temporal MR, 3 recursive spatio-temporal MR" int no default="0"
-option "levels" l "Number of resolution levels" int no default="2"
-
-
-
+++ /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://www.centreleonberard.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 clitkMultiResolutionPyramidGenericFilter_cxx
-#define clitkMultiResolutionPyramidGenericFilter_cxx
-
-/* =================================================
- * @file clitkMultiResolutionPyramidGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkMultiResolutionPyramidGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- MultiResolutionPyramidGenericFilter::MultiResolutionPyramidGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void MultiResolutionPyramidGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2,3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkMultiResolutionPyramidGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkMultiResolutionPyramidGenericFilter_h
-#define clitkMultiResolutionPyramidGenericFilter_h
-
-/* =================================================
- * @file clitkMultiResolutionPyramidGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkMultiResolutionPyramid_ggo.h"
-#include "clitkRecursiveSpatioTemporalMultiResolutionPyramidImageFilter.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkRecursiveMultiResolutionPyramidImageFilter.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT MultiResolutionPyramidGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef MultiResolutionPyramidGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( MultiResolutionPyramidGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkMultiResolutionPyramid & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- MultiResolutionPyramidGenericFilter();
- ~MultiResolutionPyramidGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkMultiResolutionPyramid m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkMultiResolutionPyramidGenericFilter.txx"
-#endif
-
-#endif // #define clitkMultiResolutionPyramidGenericFilter_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://www.centreleonberard.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 clitkMultiResolutionPyramidGenericFilter_txx
-#define clitkMultiResolutionPyramidGenericFilter_txx
-
-/* =================================================
- * @file clitkMultiResolutionPyramidGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- MultiResolutionPyramidGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- MultiResolutionPyramidGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typedef itk::ImageToImageFilter<InputImageType, OutputImageType> FilterType;
- typename FilterType::Pointer filter;
- switch(m_ArgsInfo.type_arg)
- {
- case 0:
- {
- typedef itk::MultiResolutionPyramidImageFilter<InputImageType, OutputImageType> MRFilterType;
- typename MRFilterType::Pointer rmFilter =MRFilterType::New();
- if (m_Verbose) std::cout<<"Using the multi-resolution filter..."<<std::endl;
- rmFilter->SetNumberOfLevels(m_ArgsInfo.levels_arg);
- filter=rmFilter;
- break;
- }
- case 1:
- {
- typedef itk::RecursiveMultiResolutionPyramidImageFilter<InputImageType, OutputImageType> RecursiveFilterType;
- typename RecursiveFilterType::Pointer rFilter=RecursiveFilterType::New();
- if (m_Verbose) std::cout<<"Using the recursive multi-resolution filter..."<<std::endl;
- rFilter->SetNumberOfLevels(m_ArgsInfo.levels_arg);
- rFilter->SetUseShrinkImageFilter(false);
- filter=rFilter;
- break;
- }
- case 2:
- {
- typedef clitk::SpatioTemporalMultiResolutionPyramidImageFilter<InputImageType, OutputImageType> SpatioTemporalFilterType;
- typename SpatioTemporalFilterType::Pointer spFilter=SpatioTemporalFilterType::New();
- if (m_Verbose) std::cout<<"Using the spatio-temporal multi-resolution filter..."<<std::endl;
- spFilter->SetNumberOfLevels(m_ArgsInfo.levels_arg);
- filter=spFilter;
- break;
- }
- case 3:
- {
- typedef clitk::RecursiveSpatioTemporalMultiResolutionPyramidImageFilter<InputImageType, OutputImageType> RecursiveSpatioTemporalFilterType;
- typename RecursiveSpatioTemporalFilterType::Pointer rspFilter=RecursiveSpatioTemporalFilterType::New();
- if (m_Verbose) std::cout<<"Using the recursive spatio-temporal multi-resolution filter..."<<std::endl;
- rspFilter->SetNumberOfLevels(m_ArgsInfo.levels_arg);
- rspFilter->SetUseShrinkImageFilter(false);
- filter=rspFilter;
- break;
- }
- }
-
- // Common
- filter->SetInput(input);
- try
- {
- filter->Update();
- }
- catch (itk::ExceptionObject)
- {
- std::cerr<<"Exception thrown during update() of the multi-resolution pyramid filter!"<<std::endl;
- }
-
- // Output
- for(unsigned int i=0; i< m_ArgsInfo.output_given;i++)
- {
- // Get image at level i
- typename OutputImageType::Pointer output=filter->GetOutput(i);
-
- // Write
- writeImage<OutputImageType>(output,m_ArgsInfo.output_arg[i], m_Verbose);
-// typedef itk::ImageFileWriter<OutputImageType> WriterType;
-// typename WriterType::Pointer writer = WriterType::New();
-// writer->SetFileName(m_ArgsInfo.output_arg[i]);
-// writer->SetInput(output);
-// writer->Update();
- }
- }
-
-
-}//end clitk
-
-#endif //#define clitkMultiResolutionPyramidGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkPointTrajectory.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkPointTrajectory_ggo.h"
-#include "clitkIO.h"
-#include "clitkPointTrajectoryGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkPointTrajectory, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::PointTrajectoryGenericFilter::Pointer genericFilter=clitk::PointTrajectoryGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkPointTrajectory.ggo
-package "clitkPointTrajectory"
-version "1.0"
-purpose "Compute the cyclic trajectory of a point based input transform. The transform can be given by N lists of (manually identified) landmarks, a 4DDVF or a ST transform. Interpolation is performed between "
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-section "IO"
-
-option "ref" r "Reference point list" string no
-option "phaseIncrement" p "Phase step size for the trajectory [0,10)" double no default="0.1"
-option "trajectory" o "Base filename for the trajectory files(+pointNumber) " string yes
-
-
-section "Transform: either given n lists of points; a 4DVF or the coefficient image of a spatiotemporal transform"
-option "transform" t "Transform type: 0=points, 1=4DVF, 2=coeff" int no default="0"
-option "points" - "0:Lists of points" string no multiple
-option "input" i "1,2: 4DVF or coeff image" string no
-option "interpVF" - "0,1: Interpolation: 0=NN, 1=Linear, 2=BSpline, 3=BLUT" int no default="1"
-option "interpVFOrder" - "0,1: Order if BLUT or BSpline (0-5)" int no default="3"
-option "interpVFSF" - "0,1: Sampling factor if BLUT" int no default="20"
-option "order" - "2: Spline order" int multiple no
-option "mask" m "2: Mask image filename" string no
-option "spacing" - "2: Spacing of the ref image for the sampling factor" double no default="2"
-option "shape" - "2: Shape of the transform: 0=egg, 1=diamond" int no default="0"
+++ /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://www.centreleonberard.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 clitkPointTrajectoryGenericFilter_cxx
-#define clitkPointTrajectoryGenericFilter_cxx
-
-/* =================================================
- * @file clitkPointTrajectoryGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkPointTrajectoryGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- PointTrajectoryGenericFilter::PointTrajectoryGenericFilter()
- {
- m_Verbose=false;
- // m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void PointTrajectoryGenericFilter::Update()
- {
- // ImageTypes
- const unsigned int ImageDimension=4;
- const unsigned int SpaceDimension=3;
- typedef itk::Vector<double, SpaceDimension> CoefficientPixelType;
- typedef itk::Vector<float, SpaceDimension> VectorPixelType;
- typedef itk::Image<CoefficientPixelType, ImageDimension> CoefficientImageType;
- typedef itk::Image<VectorPixelType, ImageDimension> VectorFieldType;
-
-
- // -----------------------------------------------
- // Reference Point List 3D
- // -----------------------------------------------
- typedef itk::Point<double, SpaceDimension> SpacePointType;
- typedef clitk::List<SpacePointType> PointListType;
- PointListType referencePointList;
- if (m_Verbose) std::cout<<"Reference point list:"<<std::endl;
- referencePointList=PointListType(m_ArgsInfo.ref_arg, m_Verbose);
-
-
- // -----------------------------------------------
- // Transform: based on points, 4DVF, spatio-Temporal transform
- // -----------------------------------------------
- typedef itk::Transform<double, 4, 4> TransformType;
- TransformType::Pointer transform;
- switch (m_ArgsInfo.transform_arg)
- {
- // ==========================
- // List of points
- // ==========================
- case 0:
- {
- //-----------------------------
- // Input point lists
- //-----------------------------
- typedef itk::Point<double, SpaceDimension> PointType;
- typedef clitk::List<PointType> PointListType;
- typedef clitk::Lists<PointType> PointListsType;
- PointListsType inputPointLists, sortedPointLists;
-
- // Read the lists
- for (unsigned int i=0; i<m_ArgsInfo.points_given; i++)
- inputPointLists.push_back(PointListType(m_ArgsInfo.points_arg[i], m_Verbose) );
-
- // Convert/sort the lists
- sortedPointLists.resize(inputPointLists[0].size());
- for (unsigned int i=0; i<inputPointLists[0].size(); i++)
- {
- sortedPointLists[i].push_back(referencePointList[i]);
- for (unsigned int j=0; j<inputPointLists.size(); j++)
- {
- sortedPointLists[i].push_back(inputPointLists[j][i]);
- }
- }
-
- // Point list Transform
- typedef clitk::PointListTransform<double, ImageDimension,ImageDimension> PointListTransformType;
- PointListTransformType::Pointer pointListTransform=PointListTransformType::New();
- pointListTransform->SetPointLists(sortedPointLists);
-
- // Vector Interpolator
- typedef PointListTransformType::PointListImageType PointListImageType;
- typedef clitk::GenericVectorInterpolator<args_info_clitkPointTrajectory,PointListImageType, double> GenericVectorInterpolatorType;
- GenericVectorInterpolatorType::Pointer genericInterpolator=GenericVectorInterpolatorType::New();
- genericInterpolator->SetArgsInfo(m_ArgsInfo);
- typedef itk::VectorInterpolateImageFunction<PointListImageType, double> InterpolatorType;
- InterpolatorType::Pointer interpolator=genericInterpolator->GetInterpolatorPointer();
- pointListTransform->SetInterpolator(interpolator);
- transform=pointListTransform;
-
- break;
- }
-
- // ==========================
- // 4D vector field
- // ==========================
- case 1:
- {
- // Deformation field transform
- typedef clitk::DeformationFieldTransform<double, ImageDimension,ImageDimension, SpaceDimension> DeformationFieldTransformType;
- DeformationFieldTransformType::Pointer deformationFieldTransform=DeformationFieldTransformType::New();
-
- // The deformation field
- typedef DeformationFieldTransformType::DeformationFieldType DeformationFieldType;
- typedef itk::ImageFileReader<DeformationFieldType> InputReaderType;
- InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_ArgsInfo.input_arg);
- reader->Update();
- DeformationFieldType::Pointer input= reader->GetOutput();
- deformationFieldTransform->SetDeformationField(input);
-
- // Vector Interpolator
- typedef clitk::GenericVectorInterpolator<args_info_clitkPointTrajectory,DeformationFieldType, double> GenericVectorInterpolatorType;
- GenericVectorInterpolatorType::Pointer genericInterpolator=GenericVectorInterpolatorType::New();
- genericInterpolator->SetArgsInfo(m_ArgsInfo);
- typedef itk::VectorInterpolateImageFunction<DeformationFieldType, double> InterpolatorType;
- InterpolatorType::Pointer interpolator=genericInterpolator->GetInterpolatorPointer();
- deformationFieldTransform->SetInterpolator(interpolator);
- transform=deformationFieldTransform;
-
- break;
- }
-
- // ==========================
- // Spatio-Temporal transform
- // ==========================
- case 2:
- {
- // S-T transform
- typedef clitk::ShapedBLUTSpatioTemporalDeformableTransform< double, ImageDimension, ImageDimension > TransformType;
- TransformType::Pointer spatioTemporalTransform = TransformType::New();
-
-
- // Spline orders: Default is cubic splines
- CoefficientImageType::RegionType::SizeType splineOrders ;
- splineOrders.Fill(3);
- if (m_ArgsInfo.order_given)
- for(unsigned int i=0; i<ImageDimension;i++)
- splineOrders[i]=m_ArgsInfo.order_arg[i];
- if (m_Verbose) std::cout<<"Setting the spline orders to "<<splineOrders<<"..."<<std::endl;
-
- // Coefficient image
- typedef itk::ImageFileReader<CoefficientImageType> InputReaderType;
- InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_ArgsInfo.input_arg);
- reader->Update();
- CoefficientImageType::Pointer input= reader->GetOutput();
- // itk::Vector<double,3> vector;
- // vector.Fill(0.);
- // vector[2]=100;
- // input->FillBuffer(vector);
-
- // Mask
- typedef itk::ImageMaskSpatialObject< ImageDimension > MaskType;
- MaskType::Pointer spatialObjectMask=NULL;
- if (m_ArgsInfo.mask_given)
- {
- typedef itk::Image< unsigned char, ImageDimension > ImageMaskType;
- typedef itk::ImageFileReader< ImageMaskType > MaskReaderType;
- MaskReaderType::Pointer maskReader = MaskReaderType::New();
- maskReader->SetFileName(m_ArgsInfo.mask_arg);
-
- try
- {
- maskReader->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught while reading mask !" << std::endl;
- std::cerr << err << std::endl;
- return;
- }
- if (m_Verbose)std::cout <<"Mask was read..." <<std::endl;
-
- // Set the image to the spatialObject
- spatialObjectMask = MaskType::New();
- spatialObjectMask->SetImage( maskReader->GetOutput() );
- }
-
- // Samplingfactors
- CoefficientImageType::SizeType samplingFactors;
- for (unsigned int i=0; i< ImageDimension-1; i++)
- {
- samplingFactors[i]= (int) ( input->GetSpacing()[i]/ m_ArgsInfo.spacing_arg);
- if (m_Verbose) std::cout<<"Setting sampling factor "<<i<<" to "<<samplingFactors[i]<<"..."<<std::endl;
- }
- samplingFactors[ImageDimension-1]= (int) ( input->GetSpacing()[ImageDimension-1]/ m_ArgsInfo.phaseIncrement_arg);
- if (m_Verbose) std::cout<<"Setting sampling factor "<<ImageDimension-1<<" to "<<samplingFactors[ImageDimension-1]<<"..."<<std::endl;
- if( (m_ArgsInfo.shape_arg==3) |
- (m_ArgsInfo.shape_arg==4) |
- (m_ArgsInfo.shape_arg==6) |
- (m_ArgsInfo.shape_arg==8)
- ) samplingFactors[ImageDimension-1]*=2.5;
-
- // Set
- spatioTemporalTransform->SetTransformShape(m_ArgsInfo.shape_arg);
- spatioTemporalTransform->SetSplineOrders(splineOrders);
- spatioTemporalTransform->SetMask(spatialObjectMask);
- spatioTemporalTransform->SetLUTSamplingFactors(samplingFactors);
- spatioTemporalTransform->SetCoefficientImage(input);
- transform=spatioTemporalTransform;
-
- break;
- }
-
-// // ==========================
-// // Spatio-Temporal transform
-// // ==========================
-// case 3:
-// {
-// // S-T transform
-// typedef clitk::BSplineSpatioTemporalDeformableTransform< double, ImageDimension, ImageDimension > TransformType;
-// TransformType::Pointer spatioTemporalTransform = TransformType::New();
-
-
-// // Spline orders: Default is cubic splines
-// CoefficientImageType::RegionType::SizeType splineOrders ;
-// splineOrders.Fill(3);
-// if (m_ArgsInfo.order_given)
-// for(unsigned int i=0; i<ImageDimension;i++)
-// splineOrders[i]=m_ArgsInfo.order_arg[i];
-// if (m_Verbose) std::cout<<"Setting the spline orders to "<<splineOrders<<"..."<<std::endl;
-
-// // Coefficient image
-// typedef itk::ImageFileReader<CoefficientImageType> InputReaderType;
-// InputReaderType::Pointer reader = InputReaderType::New();
-// reader->SetFileName( m_ArgsInfo.input_arg);
-// reader->Update();
-// CoefficientImageType::Pointer input= reader->GetOutput();
-// // itk::Vector<double,3> vector;
-// // vector.Fill(0.);
-// // vector[2]=100;
-// // input->FillBuffer(vector);
-
-// // Mask
-// typedef itk::ImageMaskSpatialObject< ImageDimension > MaskType;
-// MaskType::Pointer spatialObjectMask=NULL;
-// if (m_ArgsInfo.mask_given)
-// {
-// typedef itk::Image< unsigned char, ImageDimension > ImageMaskType;
-// typedef itk::ImageFileReader< ImageMaskType > MaskReaderType;
-// MaskReaderType::Pointer maskReader = MaskReaderType::New();
-// maskReader->SetFileName(m_ArgsInfo.mask_arg);
-
-// try
-// {
-// maskReader->Update();
-// }
-// catch( itk::ExceptionObject & err )
-// {
-// std::cerr << "ExceptionObject caught while reading mask !" << std::endl;
-// std::cerr << err << std::endl;
-// return;
-// }
-// if (m_Verbose)std::cout <<"Mask was read..." <<std::endl;
-
-// // Set the image to the spatialObject
-// spatialObjectMask = MaskType::New();
-// spatialObjectMask->SetImage( maskReader->GetOutput() );
-// }
-
-// // Samplingfactors
-// CoefficientImageType::SizeType samplingFactors;
-// for (unsigned int i=0; i< ImageDimension-1; i++)
-// {
-// samplingFactors[i]= (int) ( input->GetSpacing()[i]/ m_ArgsInfo.spacing_arg);
-// if (m_Verbose) std::cout<<"Setting sampling factor "<<i<<" to "<<samplingFactors[i]<<"..."<<std::endl;
-// }
-// samplingFactors[ImageDimension-1]= (int) ( input->GetSpacing()[ImageDimension-1]/ m_ArgsInfo.phaseIncrement_arg);
-// if (m_Verbose) std::cout<<"Setting sampling factor "<<ImageDimension-1<<" to "<<samplingFactors[ImageDimension-1]<<"..."<<std::endl;
-
-// // Set
-// //spatioTemporalTransform->SetTransformShape(m_ArgsInfo.shape_arg);
-// spatioTemporalTransform->SetSplineOrders(splineOrders);
-// spatioTemporalTransform->SetMask(spatialObjectMask);
-// spatioTemporalTransform->SetLUTSamplingFactors(samplingFactors);
-// spatioTemporalTransform->SetCoefficientImage(input);
-// transform=spatioTemporalTransform;
-
-// break;
-// }
- }
-
-
- // -----------------------------------------------
- // Construct Spatio-Temporal Point lists 4D
- // -----------------------------------------------
- typedef itk::Point<double, ImageDimension> SpaceTimePointType;
- typedef clitk::Lists<SpaceTimePointType> PointListsType;
- PointListsType pointLists(referencePointList.size());
- SpaceTimePointType spaceTimePoint;
- double phase;
- for (unsigned int i=0; i<referencePointList.size(); i++)
- {
- for (unsigned int d=0; d<SpaceDimension; d++)
- {
- spaceTimePoint[d]=referencePointList[i][d];
- }
- phase=0;
- while (phase<10.)
- {
- spaceTimePoint[ImageDimension-1]=phase;
- pointLists[i].push_back(spaceTimePoint);
- phase+=m_ArgsInfo.phaseIncrement_arg;
- }
- }
-
-
- // -----------------------------------------------
- // Transform Points
- // -----------------------------------------------
- typedef itk::Vector<double, ImageDimension> VectorType;
- typedef clitk::List<VectorType> VectorListType;
- typedef clitk::Lists<VectorType> VectorListsType;
- VectorListsType displacementLists(pointLists.size());
- VectorType displacement;
- for (unsigned int i=0; i<pointLists.size(); i++)
- {
- if (m_Verbose) std::cout<<"Transforming point "<<pointLists[i][0]<<"..."<<std::endl;
- for (unsigned int j=0; j<pointLists[i].size(); j++)
- {
- spaceTimePoint= transform->TransformPoint(pointLists[i][j]);
- if (m_Verbose) std::cout<<"Transformed point "<<spaceTimePoint<<"..."<<std::endl;
- displacement=spaceTimePoint-pointLists[i][j];
- displacementLists[i].push_back(displacement);
- }
- }
-
-
- // -----------------------------------------------
- // Write displacements
- // -----------------------------------------------
- std::vector<std::string> filenames;
- for (unsigned int i=0;i<displacementLists.size();i++)
- {
- std::ostringstream number_ostr;
- number_ostr << i;
- std::string number_str;
- if (i<10) number_str= "0"+number_ostr.str();
- else number_str = number_ostr.str();
- filenames.push_back(m_ArgsInfo.trajectory_arg+number_str);
- }
- displacementLists.Write(filenames, m_Verbose );
-
- }
-
-
-} //end clitk
-
-#endif //#define clitkPointTrajectoryGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkPointTrajectoryGenericFilter_h
-#define clitkPointTrajectoryGenericFilter_h
-
-/* =================================================
- * @file clitkPointTrajectoryGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkPointTrajectory_ggo.h"
-#include "clitkPointListTransform.h"
-#include "clitkDeformationFieldTransform.h"
-#include "clitkShapedBLUTSpatioTemporalDeformableTransform.h"
-#include "clitkLists.h"
-#include "clitkGenericVectorInterpolator.h"
-
-
-//itk include
-#include "itkLightObject.h"
-#include "itkTransform.h"
-#include "itkImageMaskSpatialObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT PointTrajectoryGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef PointTrajectoryGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( PointTrajectoryGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkPointTrajectory & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- PointTrajectoryGenericFilter();
- ~PointTrajectoryGenericFilter() {};
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkPointTrajectory m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-
-#endif // #define clitkPointTrajectoryGenericFilter_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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkResampleBSplineDeformableTransform.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkResampleBSplineDeformableTransform_ggo.h"
-#include "clitkIO.h"
-#include "clitkResampleBSplineDeformableTransformGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkResampleBSplineDeformableTransform, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::ResampleBSplineDeformableTransformGenericFilter::Pointer genericFilter=clitk::ResampleBSplineDeformableTransformGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkResampleBSplineDeformableTransform.ggo
-package "clitkResampleBSplineDeformableTransform"
-version "1.0"
-purpose "Resample the B-spline control point grid to given properties. Coefficients are resampled to values with the desired properties and reconverted to coefficients "
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "like" - "Resample output like this image" string no
-
-
-section "Output Image Properties"
-
-option "origin" - "Origin for the output image" double multiple no
-option "size" - "Size for the output image" int multiple no
-option "spacing" - "Spacing for the output image" double multiple no
-
-
-
-
+++ /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://www.centreleonberard.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 clitkResampleBSplineDeformableTransformGenericFilter_cxx
-#define clitkResampleBSplineDeformableTransformGenericFilter_cxx
-
-/* =================================================
- * @file clitkResampleBSplineDeformableTransformGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkResampleBSplineDeformableTransformGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- ResampleBSplineDeformableTransformGenericFilter::ResampleBSplineDeformableTransformGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void ResampleBSplineDeformableTransformGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension, Components;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
- else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
- else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
- else
- {
- std::cout<<"Error, Only for 2,3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-} //end clitk
-
-#endif //#define clitkResampleBSplineDeformableTransformGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkResampleBSplineDeformableTransformGenericFilter_h
-#define clitkResampleBSplineDeformableTransformGenericFilter_h
-
-/* =================================================
- * @file clitkResampleBSplineDeformableTransformGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkResampleBSplineDeformableTransform_ggo.h"
-#include "clitkResampleBSplineDeformableTransformImageFilter.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT ResampleBSplineDeformableTransformGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef ResampleBSplineDeformableTransformGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( ResampleBSplineDeformableTransformGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkResampleBSplineDeformableTransform & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- ResampleBSplineDeformableTransformGenericFilter();
- ~ResampleBSplineDeformableTransformGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, int Components);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkResampleBSplineDeformableTransform m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkResampleBSplineDeformableTransformGenericFilter.txx"
-#endif
-
-#endif // #define clitkResampleBSplineDeformableTransformGenericFilter_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://www.centreleonberard.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 clitkResampleBSplineDeformableTransformGenericFilter_txx
-#define clitkResampleBSplineDeformableTransformGenericFilter_txx
-
-/* =================================================
- * @file clitkResampleBSplineDeformableTransformGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- ResampleBSplineDeformableTransformGenericFilter::UpdateWithDim(std::string PixelType, int Components)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
-
- if (Components==2)
- {
- if(PixelType == "double"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 2D double..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, itk::Vector<double,2 > >();
- }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 2D float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, itk::Vector<float,2 > >();
- }
- }
- else if (Components==3)
- {
- if(PixelType == "double"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D double..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, itk::Vector<double,3 > >();
- }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, itk::Vector<float,3 > >();
- }
- }
- else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- ResampleBSplineDeformableTransformGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typedef clitk::ResampleBSplineDeformableTransformImageFilter<InputImageType,OutputImageType> ResampleFilterType;
- typename ResampleFilterType::Pointer filter=ResampleFilterType::New();
- filter->SetInput(input);
-
- // Output image info
- if (m_ArgsInfo.like_given)
- {
- typename InputReaderType::Pointer likeReader=InputReaderType::New();
- likeReader->SetFileName(m_ArgsInfo.like_arg);
- likeReader->Update();
- filter->SetOutputParametersFromImage(likeReader->GetOutput());
- }
- else
- {
- // Size
- typename OutputImageType::SizeType outputSize;
- if (m_ArgsInfo.size_given)
- {
- for(unsigned int i=0; i< Dimension; i++)
- outputSize[i]=m_ArgsInfo.size_arg[i];
- }
- else outputSize=input->GetLargestPossibleRegion().GetSize();
- if (m_Verbose) std::cout<<"Setting the size to "<<outputSize<<"..."<<std::endl;
-
- // Spacing
- typename OutputImageType::SpacingType outputSpacing;
- if (m_ArgsInfo.spacing_given)
- {
- for(unsigned int i=0; i< Dimension; i++)
- outputSpacing[i]=m_ArgsInfo.spacing_arg[i];
- }
- else outputSpacing=input->GetSpacing();
- if (m_Verbose) std::cout<<"Setting the spacing to "<<outputSpacing<<"..."<<std::endl;
-
- // Origin
- typename OutputImageType::PointType outputOrigin;
- if (m_ArgsInfo.origin_given)
- {
- for(unsigned int i=0; i< Dimension; i++)
- outputOrigin[i]=m_ArgsInfo.origin_arg[i];
- }
- else outputOrigin=input->GetOrigin();
- if (m_Verbose) std::cout<<"Setting the origin to "<<outputOrigin<<"..."<<std::endl;
-
- // Set
- filter->SetSize( outputSize );
- filter->SetOutputSpacing( outputSpacing );
- filter->SetOutputOrigin( outputOrigin );
-
- }
-
- // Go
- filter->Update();
-
- // Get the output
- typename OutputImageType::Pointer output=filter->GetOutput();
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkResampleBSplineDeformableTransformGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkSelectPoints.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkSelectPoints_ggo.h"
-#include "clitkIO.h"
-#include "clitkSelectPointsGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkSelectPoints, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::SelectPointsGenericFilter::Pointer genericFilter=clitk::SelectPointsGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkSelectPoints.ggo
-package "clitkSelectPoints"
-version "1.0"
-purpose "Perform a selection of points on the reference and target lists of points, based on criteria applied to the reference list."
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-section "Input"
-
-option "ref" r "List of points in reference" string yes
-option "input" i "Lists of points in targets" string multiple yes
-
-
-section "Output"
-
-option "sRef" - "List of points selected in reference" string yes
-option "sInput" o "Lists of points selected in targets" string multiple yes
-
-section "Selection: Provide lower and upper coordinate bounds for as much as components as provided"
-
-option "component" c "Component index [0,2]" int multiple yes
-option "lower" l "Lower bound" double multiple yes
-option "upper" u "Upper bound" double multiple yes
+++ /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://www.centreleonberard.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 clitkSelectPointsGenericFilter_cxx
-#define clitkSelectPointsGenericFilter_cxx
-
-/* =================================================
- * @file clitkSelectPointsGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkSelectPointsGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- SelectPointsGenericFilter::SelectPointsGenericFilter()
- {
- m_Verbose=false;
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void SelectPointsGenericFilter::Update()
- {
- //-----------------------------
- // Typedefs
- //-----------------------------
- typedef double ValueType;
- typedef std::vector<ValueType> MeasureListType;
-
- typedef itk::Point<double, 3> PointType;
- typedef clitk::List<PointType> PointListType;
- typedef clitk::Lists<PointType> PointListsType;
-
-
- //-----------------------------
- // Input point lists
- //-----------------------------
- PointListsType pointLists;
- unsigned int numberOfPoints=0;
- unsigned int numberOfLists=m_ArgsInfo.input_given;
- for (unsigned int i=0; i<numberOfLists; i++)
- {
- // Read the lists
- pointLists.push_back(PointListType(m_ArgsInfo.input_arg[i], m_Verbose) );
-
- // Verify the number of points
- if (i==0) numberOfPoints=pointLists[i].size();
- else
- {
- if (numberOfPoints!=pointLists[i].size())
- {
- std::cerr<<"Size of first list ("<<numberOfPoints
- <<") is different from size of list "<<i
- <<" ("<<pointLists[i].size()<<")..."<<std::endl;
- return;
- }
- }
- }
-
- //-----------------------------
- // Reference point list
- //-----------------------------
- PointListType referencePointList;
- if (m_Verbose) std::cout<<"Reference point list:"<<std::endl;
- referencePointList=PointListType(m_ArgsInfo.ref_arg, m_Verbose);
- if (numberOfPoints!=referencePointList.size())
- {
- std::cerr<<"Size of the first list ("<<numberOfPoints
- <<") is different from size of the reference list ("
- << referencePointList.size() <<")..."<<std::endl;
- return;
- }
-
-
- //-----------------------------
- // Select
- //-----------------------------
- PointListType sReferencePointList;
- PointListsType sPointLists(numberOfLists);
- unsigned int counter=0;
- for (unsigned int number=0; number< referencePointList.size(); number++)
- {
- for (unsigned int component=0; component< m_ArgsInfo.component_given; component++)
- {
- if ( (referencePointList[number][m_ArgsInfo.component_arg[component]] >= m_ArgsInfo.lower_arg[component])
- && (referencePointList[number][m_ArgsInfo.component_arg[component]] <= m_ArgsInfo.upper_arg[component]) )
- {
- if(m_Verbose) std::cout<<"Selecting point "<<number<<": "<<referencePointList[number]<<std::endl;
- sReferencePointList.push_back(referencePointList[number]);
- for (unsigned int i=0;i<pointLists.size();i++)
- sPointLists[i].push_back(pointLists[i][number]);
- counter++;
- }
- }
- }
- if (m_Verbose) std::cout<<"Selected "<<counter<<" points..."<<std::endl;
-
-
-
- //-----------------------------
- // Output
- //-----------------------------
- sReferencePointList.Write(m_ArgsInfo.sRef_arg,m_Verbose);
- std::vector<std::string> filenames;
- for (unsigned int i=0;i<pointLists.size();i++)
- filenames.push_back(m_ArgsInfo.sInput_arg[i]);
- sPointLists.Write(filenames,m_Verbose);
-
- }
-
-
-} //end clitk
-
-#endif //#define clitkSelectPointsGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkSelectPointsGenericFilter_h
-#define clitkSelectPointsGenericFilter_h
-
-/* =================================================
- * @file clitkSelectPointsGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkSelectPoints_ggo.h"
-#include "clitkList.h"
-#include "clitkLists.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT SelectPointsGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef SelectPointsGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( SelectPointsGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkSelectPoints & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- SelectPointsGenericFilter();
- ~SelectPointsGenericFilter() {};
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkSelectPoints m_ArgsInfo;
- bool m_Verbose;
-
- };
-
-
-} // end namespace clitk
-
-
-#endif // #define clitkSelectPointsGenericFilter_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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkShapedBLUTSpatioTemporalDIR.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkShapedBLUTSpatioTemporalDIR_ggo.h"
-#include "clitkIO.h"
-#include "clitkShapedBLUTSpatioTemporalDIRGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkShapedBLUTSpatioTemporalDIR, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::ShapedBLUTSpatioTemporalDIRGenericFilter::Pointer genericFilter=clitk::ShapedBLUTSpatioTemporalDIRGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkShapedBLUTSpatioTemporalDIR.ggo
-#Author: Jef Vandemeulebroucke <jefvdmb@gmail.com>
-#Date : Tue 15 Jan 2009 10.35
-
-package "clitk"
-version "Deform a volume to match a temporal sequence using a spatio-temporal deformation model. By setting the shape of the model, you modify the temporal constraints applied to the cyclic trajectory model."
-
-option "config" - "Config file" string no
-
-
-section "Run Time"
-
-option "verbose" v "Verbose" flag off
-option "threads" - "Number of threads to use (default=min(#cores,8))" int no
-
-
-section "Input"
-
-option "reference" r "Input reference 3D image (float)" string yes
-option "target" t "Input target 2D image (float)" string yes
-option "referenceMask" m "Mask to placed over the reference image" string no
-option "targetMask" - "Mask to placed over the target image" string no
-
-
-section "Output"
-
-option "vf" - "Result DVF" string yes
-option "coeff" - "Result coefficient images" string no
-option "padCoeff" - "Result padded coefficient images" string no
-option "output" o "Deformed target image" string yes
-option "before" - "Difference image before (but after rigid transform)" string no
-option "after" - "Difference image after " string no
-option "current" - "Write the current coefficient image every N evaluations" int no
-option "intermediate" - "Write the coefficient image at resolution levels (provide N filenames)" string no multiple
-
-
-section "Transform (Note that only one of --control, --spacing is required. The other will be adjusted to fit the region and allow exact representation. SamplingFactor will be set accordingly"
-
-option "shape" - "Even=4 internal CP, Odd 5 internal CP: 0,1=egg; 2,3= rabbit; 4,5=sputnik; 6,7=diamond" int no default="3"
-option "initCoeff" - "Initial coefficient image (without borders)" string no
-option "initPadCoeff" - "Initial padded coefficient image (with borders)" string no
-option "rigid" - "Prior rigid transform matrix from reference to target space" string no
-option "order" - "Spline Order FFD" int no multiple default="3"
-option "control" - "Internal control points for each dimension" int no multiple
-option "spacing" - "Control point spacing for each dimension (mm)" double no multiple
-option "samplingFactor" - "LUT sampling factor" int no multiple
-
-
-section "Interpolator"
-
-option "interp" - "Interpolation: 0=NN, 1=Linear, 2=BSpline, 3=BLUT" int no default="1"
-option "interpOrder" - "Order if BLUT or BSpline (0-5)" int no default="3"
-option "interpSF" - "Sampling factor if BLUT" int no default="20"
-
-
-section "Metric (optimized, threaded versions are available for *, compile ITK with REVIEW and OPT_REGISTRATION enabled. Further optimized versions ** for BLUT FFD optimizing a !3D! vector field)"
-
-option "metric" - "Type: 0=SSD*, 1=Normalized CC*, 2=Histogram CC, 3=Gradient-Difference, 4=Viola-Wells MI, 5=Histogram MI, 6=Mattes' MI*, 7=Normalized MI, 8=CR, 9=SSD for BLUT FFD**, 10=CC for BLUT FFD**, 11=Mattes' MI for BLUT FFD**" int no default="0"
-option "samples" - "Specify fraction [0, 1] of samples of the reference image used for the metric (* only). Use high fraction for detailed images (eg. 0.2, 0.5), for smooth images 0.01 might be enough." float no default="1"
-option "intThreshold" - "Fixed image samples intensity threshold (* only)" float no
-option "subtractMean" - "1: Subtract mean for NCC calculation (narrows optimal)" flag on
-option "bins" - "2,5-8: Number of histogram bins" int no default="50"
-option "random" - "4,6: Samples should be taken randomly, otherwise uniformly" flag off
-option "stdDev" - "4: specify the standard deviation in mm of the gaussian kernels for both PDF estimations" float no default="0.4"
-option "explicitPDFDerivatives" - "6: Calculate PDF derivatives explicitly (rigid=true; FFD=false)" flag off
-
-
-section "Optimizer"
-
-option "optimizer" - "0=Simplex, 1=Powell, 2=FRPR, 3=Regular Step GD, 4=VersorRigid3D, 5=Conjugated Gradient, 6=L-BFGS, 7=L-BFGS-B" int no default="7"
-option "delta" - "0: Initial delta, otherwise automatic" double no
-option "step" - "1,2,3,4: Initial stepsize (to be multiplied with the gradient)" double no default="2.0"
-option "relax" - "3,4: Relaxation of the stepsize (multiplied each time the gradient changes sign)" double no default="0.7"
-option "valueTol" - "0,1,2: Tolerance on the function" double no default="0.01"
-option "stepTol" - "0,1,3,4: Tolerance on the step size" double no default="0.1"
-option "gradTol" - "3,4,6,7: Tolerance on the (projected) gradient magnitude (7: 1=low->1e-10=high precision)" double no default="1e-5"
-option "lineAcc" - "6: Line accuracy (eg: high=0.1, low=0.9)" double no default="0.9"
-option "convFactor" - "7: Convergence factor: terminate if factor*machine_precision>reduction in cost (1e+12 low -> 1e+1 high precision) " double no default="1e+7"
-option "maxIt" - "0-7: Maximum number of iterations" int no default="500"
-option "maxLineIt" - "1,2: Maximum number of line iterations" int no default="50"
-option "maxEval" - "6,7: Maximum number of evaluations" int no default="500"
-option "maxCorr" - "7: Maximum number of corrections" int no default="5"
-option "selectBound" - "7: Select the type of bound: 0=none, 1=u, 2=u&l, 3=l" int no default="0"
-option "lowerBound" - "7: The lower bound" double no default="0.0"
-option "upperBound" - "7: The upper bound" double no default="0.0"
-
-
-section "Registration"
-
-option "levels" - "Number of resolution levels" int no default="1"
+++ /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://www.centreleonberard.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 clitkShapedBLUTSpatioTemporalDIRGenericFilter_cxx
-#define clitkShapedBLUTSpatioTemporalDIRGenericFilter_cxx
-
-/* =================================================
- * @file clitkShapedBLUTSpatioTemporalDIRGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkShapedBLUTSpatioTemporalDIRGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- ShapedBLUTSpatioTemporalDIRGenericFilter::ShapedBLUTSpatioTemporalDIRGenericFilter()
- {
- m_Verbose=false;
- m_ReferenceFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void ShapedBLUTSpatioTemporalDIRGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_ReferenceFileName, Dimension, PixelType);
-
- //if(Dimension==3) UpdateWithDim<3>(PixelType);
- //else
- if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkShapedBLUTSpatioTemporalDIRGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkShapedBLUTSpatioTemporalDIRGenericFilter_h
-#define clitkShapedBLUTSpatioTemporalDIRGenericFilter_h
-
-/* =================================================
- * @file clitkShapedBLUTSpatioTemporalDIRGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkShapedBLUTSpatioTemporalDIR_ggo.h"
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkGenericOptimizer.h"
-#include "clitkGenericMetric.h"
-#include "clitkGenericInterpolator.h"
-#include "clitkShapedBLUTSpatioTemporalDeformableTransform.h"
-#include "clitkShapedBLUTSpatioTemporalDeformableTransformInitializer.h"
-#include "clitkSpatioTemporalMultiResolutionImageRegistrationMethod.h"
-#include "clitkSpatioTemporalMultiResolutionPyramidImageFilter.h"
-#include "clitkDifferenceImageFilter.h"
-#include "clitkMultiResolutionPyramidRegionFilter.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkLabelStatisticsImageFilter.h"
-#include "itkImageMaskSpatialObject.h"
-#include "itkImageToImageMetric.h"
-#include "itkInterpolateImageFunction.h"
-#include "itkWarpImageFilter.h"
-#include "itkImageDuplicator.h"
-#include "itkExtractImageFilter.h"
-#include "itkCropImageFilter.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT ShapedBLUTSpatioTemporalDIRGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef ShapedBLUTSpatioTemporalDIRGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( ShapedBLUTSpatioTemporalDIRGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkShapedBLUTSpatioTemporalDIR & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_ReferenceFileName=m_ArgsInfo.reference_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- ShapedBLUTSpatioTemporalDIRGenericFilter();
- ~ShapedBLUTSpatioTemporalDIRGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkShapedBLUTSpatioTemporalDIR m_ArgsInfo;
- bool m_Verbose;
- std::string m_ReferenceFileName;
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkShapedBLUTSpatioTemporalDIRGenericFilter.txx"
-#endif
-
-#endif // #define clitkShapedBLUTSpatioTemporalDIRGenericFilter_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://www.centreleonberard.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 clitkShapedBLUTSpatioTemporalDIRGenericFilter_txx
-#define clitkShapedBLUTSpatioTemporalDIRGenericFilter_txx
-
-/* =================================================
- * @file clitkShapedBLUTSpatioTemporalDIRGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkShapedBLUTSpatioTemporalDIRGenericFilter.h"
-
-namespace clitk
-{
-
- //==============================================================================
- // Creating an observer class that allows output at each iteration
- //==============================================================================
- template <typename TRegistration, class args_info_clitkShapedBLUTSpatioTemporalDIR>
- class CommandIterationUpdate : public itk::Command
- {
- public:
- typedef CommandIterationUpdate Self;
- typedef itk::Command Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- itkNewMacro( Self );
-
- // Registration
- typedef TRegistration RegistrationType;
- typedef RegistrationType * RegistrationPointer;
-
- // Transform
- typedef typename RegistrationType::FixedImageType FixedImageType;
- typedef typename FixedImageType::RegionType RegionType;
- itkStaticConstMacro(ImageDimension, unsigned int,FixedImageType::ImageDimension);
- typedef clitk::ShapedBLUTSpatioTemporalDeformableTransform<double, ImageDimension, ImageDimension> TransformType;
- typedef clitk::ShapedBLUTSpatioTemporalDeformableTransformInitializer<TransformType, FixedImageType> InitializerType;
- typedef typename InitializerType::CoefficientImageType CoefficientImageType;
- typedef itk::CastImageFilter<CoefficientImageType, CoefficientImageType> CastImageFilterType;
- typedef typename TransformType::ParametersType ParametersType;
- typedef typename InitializerType::Pointer InitializerPointer;
-
- protected:
- CommandIterationUpdate() { m_IterationCounter=0;}
- public:
- typedef clitk::GenericOptimizer<args_info_clitkShapedBLUTSpatioTemporalDIR> OptimizerType;
- typedef const OptimizerType * OptimizerPointer;
-
- // Execute
- void Execute(itk::Object *caller, const itk::EventObject & event)
- {
- Execute( (const itk::Object *)caller, event);
- }
-
- void Execute(const itk::Object * object, const itk::EventObject & event)
- {
- if( !(itk::IterationEvent().CheckEvent( &event )) )
- {
- return;
- }
-
- // Output
- m_Optimizer->OutputIterationInfo();
- m_IterationCounter++;
-
- // Write intermediate result
- if (m_ArgsInfo.current_given && (m_IterationCounter> m_ArgsInfo.current_arg) )
- {
- // Write && Reset
- writeImage<CoefficientImageType>(m_Initializer->GetTransform()->GetCoefficientImage(), m_ArgsInfo.coeff_arg, m_ArgsInfo.verbose_flag );
- m_IterationCounter=0;
- }
- }
-
- // Members
- void SetOptimizer(OptimizerPointer o){m_Optimizer=o;}
- OptimizerPointer m_Optimizer;
-
- void SetInitializer(InitializerPointer i){m_Initializer=i;}
- InitializerPointer m_Initializer;
-
- void SetArgsInfo(args_info_clitkShapedBLUTSpatioTemporalDIR a){m_ArgsInfo=a;}
- args_info_clitkShapedBLUTSpatioTemporalDIR m_ArgsInfo;
-
- int m_IterationCounter;
- };
-
-
- //==============================================================================
- //Creating an observer class that allows us to change parameters at subsequent levels
- //==============================================================================
- template <typename TRegistration, class args_info_clitkShapedBLUTSpatioTemporalDIR>
- class RegistrationInterfaceCommand : public itk::Command
- {
- public:
- typedef RegistrationInterfaceCommand Self;
- typedef itk::Command Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- itkNewMacro( Self );
- protected:
- RegistrationInterfaceCommand() {};
- public:
-
- // Registration
- typedef TRegistration RegistrationType;
- typedef RegistrationType * RegistrationPointer;
-
- // Transform
- typedef typename RegistrationType::FixedImageType FixedImageType;
- typedef typename FixedImageType::RegionType RegionType;
- itkStaticConstMacro(ImageDimension, unsigned int,FixedImageType::ImageDimension);
- typedef clitk::ShapedBLUTSpatioTemporalDeformableTransform<double, ImageDimension, ImageDimension> TransformType;
- typedef clitk::ShapedBLUTSpatioTemporalDeformableTransformInitializer<TransformType, FixedImageType> InitializerType;
- typedef typename InitializerType::CoefficientImageType CoefficientImageType;
- typedef itk::CastImageFilter<CoefficientImageType, CoefficientImageType> CastImageFilterType;
- typedef typename TransformType::ParametersType ParametersType;
- typedef typename InitializerType::Pointer InitializerPointer;
- typedef typename CommandIterationUpdate< TRegistration, args_info_clitkShapedBLUTSpatioTemporalDIR>::Pointer CommandIterationUpdatePointer;
-
- // Optimizer
- typedef clitk::GenericOptimizer<args_info_clitkShapedBLUTSpatioTemporalDIR> GenericOptimizerType;
- typedef typename GenericOptimizerType::Pointer GenericOptimizerPointer;
-
- // Metric
- typedef typename RegistrationType::FixedImageType InternalImageType;
- typedef clitk::GenericMetric<args_info_clitkShapedBLUTSpatioTemporalDIR, InternalImageType, InternalImageType> GenericMetricType;
- typedef typename GenericMetricType::Pointer GenericMetricPointer;
-
- // Two arguments are passed to the Execute() method: the first
- // is the pointer to the object which invoked the event and the
- // second is the event that was invoked.
- void Execute(itk::Object * object, const itk::EventObject & event)
- {
- if( !(itk::IterationEvent().CheckEvent( &event )) )
- {
- return;
- }
-
- // Get the levels
- RegistrationPointer registration = dynamic_cast<RegistrationPointer>( object );
- unsigned int numberOfLevels=registration->GetNumberOfLevels();
- unsigned int currentLevel=registration->GetCurrentLevel()+1;
-
- // Output the levels
- std::cout<<std::endl;
- std::cout<<"========================================"<<std::endl;
- std::cout<<"Starting resolution level "<<currentLevel<<" of "<<numberOfLevels<<"..."<<std::endl;
- std::cout<<"========================================"<<std::endl;
- std::cout<<std::endl;
-
- // Higher level?
- if (currentLevel>1)
- {
- // fixed image region pyramid
- typedef clitk::MultiResolutionPyramidRegionFilter<InternalImageType> FixedImageRegionPyramidType;
- typename FixedImageRegionPyramidType::Pointer fixedImageRegionPyramid=FixedImageRegionPyramidType::New();
- fixedImageRegionPyramid->SetRegion(m_MetricRegion);
- fixedImageRegionPyramid->SetSchedule(registration->GetFixedImagePyramid()->GetSchedule());
-
- // Reinitialize the metric (!= number of samples)
- m_GenericMetric= GenericMetricType::New();
- m_GenericMetric->SetArgsInfo(m_ArgsInfo);
- m_GenericMetric->SetFixedImage(registration->GetFixedImagePyramid()->GetOutput(registration->GetCurrentLevel()));
- if (m_ArgsInfo.referenceMask_given) m_GenericMetric->SetFixedImageMask(registration->GetMetric()->GetFixedImageMask());
- m_GenericMetric->SetFixedImageRegion(fixedImageRegionPyramid->GetOutput(registration->GetCurrentLevel()));
- typedef itk::ImageToImageMetric< InternalImageType, InternalImageType > MetricType;
- typename MetricType::Pointer metric=m_GenericMetric->GetMetricPointer();
- registration->SetMetric(metric);
-
- // Get the current coefficient image and make a COPY
- typename itk::ImageDuplicator<CoefficientImageType>::Pointer caster=itk::ImageDuplicator<CoefficientImageType>::New();
- caster->SetInputImage(m_Initializer->GetTransform()->GetCoefficientImage());
- caster->Update();
- typename CoefficientImageType::Pointer currentCoefficientImage=caster->GetOutput();
-
- // Write the intermediate result?
- if (m_ArgsInfo.intermediate_given>=numberOfLevels)
- writeImage<CoefficientImageType>(currentCoefficientImage, m_ArgsInfo.intermediate_arg[currentLevel-2], m_ArgsInfo.verbose_flag);
-
- // Set the new transform properties
- m_Initializer->SetImage(registration->GetFixedImagePyramid()->GetOutput(currentLevel-1));
- if( m_Initializer->m_ControlPointSpacingIsGiven)
- m_Initializer->SetControlPointSpacing(m_Initializer->m_ControlPointSpacingArray[registration->GetCurrentLevel()]);
- if( m_Initializer->m_NumberOfControlPointsIsGiven)
- m_Initializer->SetNumberOfControlPointsInsideTheImage(m_Initializer->m_NumberOfControlPointsInsideTheImageArray[registration->GetCurrentLevel()]);
-
- // Reinitialize the transform
- if (m_ArgsInfo.verbose_flag) std::cout<<"Initializing transform for level "<<currentLevel<<" of "<<numberOfLevels<<"..."<<std::endl;
- m_Initializer->InitializeTransform();
- ParametersType* newParameters= new typename TransformType::ParametersType(m_Initializer->GetTransform()->GetNumberOfParameters());
-
- // Reinitialize an Optimizer (!= number of parameters)
- m_GenericOptimizer = GenericOptimizerType::New();
- m_GenericOptimizer->SetArgsInfo(m_ArgsInfo);
- m_GenericOptimizer->SetMaximize(m_Maximize);
- m_GenericOptimizer->SetNumberOfParameters(m_Initializer->GetTransform()->GetNumberOfParameters());
- typedef itk::SingleValuedNonLinearOptimizer OptimizerType;
- OptimizerType::Pointer optimizer = m_GenericOptimizer->GetOptimizerPointer();
- optimizer->AddObserver( itk::IterationEvent(), m_CommandIterationUpdate);
- registration->SetOptimizer(optimizer);
- m_CommandIterationUpdate->SetOptimizer(m_GenericOptimizer);
-
- // Set the previous transform parameters to the registration
- // if(m_Initializer->m_Parameters!=NULL )delete m_Initializer->m_Parameters;
- m_Initializer->SetInitialParameters(currentCoefficientImage,*newParameters);
- registration->SetInitialTransformParametersOfNextLevel(*newParameters);
- }
- }
-
- void Execute(const itk::Object * , const itk::EventObject & )
- { return; }
-
-
- // Members
- void SetInitializer(InitializerPointer i){m_Initializer=i;}
- InitializerPointer m_Initializer;
-
- void SetArgsInfo(args_info_clitkShapedBLUTSpatioTemporalDIR a){m_ArgsInfo=a;}
- args_info_clitkShapedBLUTSpatioTemporalDIR m_ArgsInfo;
-
- void SetCommandIterationUpdate(CommandIterationUpdatePointer c){m_CommandIterationUpdate=c;};
- CommandIterationUpdatePointer m_CommandIterationUpdate;
-
- GenericOptimizerPointer m_GenericOptimizer;
- void SetMaximize(bool b){m_Maximize=b;}
- bool m_Maximize;
-
- GenericMetricPointer m_GenericMetric;
- void SetMetricRegion(RegionType i){m_MetricRegion=i;}
- RegionType m_MetricRegion;
-
-
- };
-
-
- //==============================================================================
- // Update with the number of dimensions
- //==============================================================================
- template<unsigned int Dimension>
- void
- ShapedBLUTSpatioTemporalDIRGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- // else if (PixelType == "unsigned_char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned char>();
- // }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //==============================================================================
- // Update with the number of dimensions and pixeltype
- //==============================================================================
- template<unsigned int ImageDimension, class PixelType>
- void
- ShapedBLUTSpatioTemporalDIRGenericFilter::UpdateWithDimAndPixelType()
- {
-
-
- //=============================================================================
- //Input
- //=============================================================================
- bool threadsGiven=m_ArgsInfo.threads_given;
- int threads=m_ArgsInfo.threads_arg;
-
- typedef itk::Image< PixelType, ImageDimension > FixedImageType;
- typedef itk::Image< PixelType, ImageDimension > MovingImageType;
- const unsigned int SpaceDimension = ImageDimension-1;
- typedef double TCoordRep;
-
-
- //=======================================================
- //Input
- //=======================================================
- typedef itk::ImageFileReader< FixedImageType > FixedImageReaderType;
- typedef itk::ImageFileReader< MovingImageType > MovingImageReaderType;
-
- typename FixedImageReaderType::Pointer fixedImageReader = FixedImageReaderType::New();
- typename MovingImageReaderType::Pointer movingImageReader = MovingImageReaderType::New();
-
- fixedImageReader->SetFileName( m_ArgsInfo.reference_arg );
- movingImageReader->SetFileName( m_ArgsInfo.target_arg );
- if (m_Verbose) std::cout<<"Reading images..."<<std::endl;
- fixedImageReader->Update();
- movingImageReader->Update();
-
- typename FixedImageType::Pointer fixedImage = fixedImageReader->GetOutput();
- typename MovingImageType::Pointer movingImage =movingImageReader->GetOutput();
- typename FixedImageType::Pointer croppedFixedImage=fixedImage;
-
-
- //=======================================================
- // Regions
- //=======================================================
-
- // The original input region
- typename FixedImageType::RegionType fixedImageRegion = fixedImage->GetLargestPossibleRegion();
-
- // The transform region with respect to the input region:
- // where should the transform be DEFINED (depends on mask)
- typename FixedImageType::RegionType transformRegion = fixedImage->GetLargestPossibleRegion();
- typename FixedImageType::RegionType::SizeType transformRegionSize=transformRegion.GetSize();
- typename FixedImageType::RegionType::IndexType transformRegionIndex=transformRegion.GetIndex();
- typename FixedImageType::PointType transformRegionOrigin=fixedImage->GetOrigin();
-
- // The metric region with respect to the extracted transform region:
- // where should the metric be CALCULATED (depends on transform)
- typename FixedImageType::RegionType metricRegion = fixedImage->GetLargestPossibleRegion();
- typename FixedImageType::RegionType::SizeType metricRegionSize=metricRegion.GetSize();
- typename FixedImageType::RegionType::IndexType metricRegionIndex=metricRegion.GetIndex();
- typename FixedImageType::PointType metricRegionOrigin=fixedImage->GetOrigin();
-
- //===========================================================================
- // If given, we connect a mask to reference or target
- //============================================================================
- typedef itk::ImageMaskSpatialObject< ImageDimension > MaskType;
- typename MaskType::Pointer fixedMask=NULL;
- if (m_ArgsInfo.referenceMask_given)
- {
- fixedMask= MaskType::New();
- typedef itk::Image< unsigned char, ImageDimension > ImageMaskType;
- typedef itk::ImageFileReader< ImageMaskType > MaskReaderType;
- typename MaskReaderType::Pointer maskReader = MaskReaderType::New();
- maskReader->SetFileName(m_ArgsInfo.referenceMask_arg);
- try
- {
- maskReader->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught while reading mask !" << std::endl;
- std::cerr << err << std::endl;
- return;
- }
- if (m_Verbose)std::cout <<"Reference image mask was read..." <<std::endl;
-
- // Set the image to the spatialObject
- fixedMask->SetImage( maskReader->GetOutput() );
-
- // Find the bounding box of the "inside" label
- typedef itk::LabelStatisticsImageFilter<ImageMaskType, ImageMaskType> StatisticsImageFilterType;
- typename StatisticsImageFilterType::Pointer statisticsImageFilter=StatisticsImageFilterType::New();
- statisticsImageFilter->SetInput(maskReader->GetOutput());
- statisticsImageFilter->SetLabelInput(maskReader->GetOutput());
- statisticsImageFilter->Update();
- typename StatisticsImageFilterType::BoundingBoxType boundingBox = statisticsImageFilter->GetBoundingBox(1);
-
- // Limit the transform region to the mask
- for (unsigned int i=0; i<ImageDimension; i++)
- {
- transformRegionIndex[i]=boundingBox[2*i];
- transformRegionSize[i]=boundingBox[2*i+1]-boundingBox[2*i]+1;
- }
- transformRegion.SetSize(transformRegionSize);
- transformRegion.SetIndex(transformRegionIndex);
- fixedImage->TransformIndexToPhysicalPoint(transformRegion.GetIndex(), transformRegionOrigin);
-
- // Crop the fixedImage to the bounding box to facilitate multi-resolution
- typedef itk::ExtractImageFilter<FixedImageType,FixedImageType> ExtractImageFilterType;
- typename ExtractImageFilterType::Pointer extractImageFilter=ExtractImageFilterType::New();
- extractImageFilter->SetInput(fixedImage);
- extractImageFilter->SetExtractionRegion(transformRegion);
- extractImageFilter->Update();
- croppedFixedImage=extractImageFilter->GetOutput();
-
- // Update the metric region
- metricRegion = croppedFixedImage->GetLargestPossibleRegion();
- metricRegionIndex=metricRegion.GetIndex();
- metricRegionSize=metricRegion.GetSize();
- croppedFixedImage->TransformIndexToPhysicalPoint(metricRegionIndex, metricRegionOrigin);
-
- // Set start index to zero (with respect to croppedFixedImage/transform region)
- metricRegionIndex.Fill(0);
- metricRegion.SetIndex(metricRegionIndex);
- croppedFixedImage->SetRegions(metricRegion);
- croppedFixedImage->SetOrigin(metricRegionOrigin);
-
- }
-
- typedef itk::ImageMaskSpatialObject< ImageDimension > MaskType;
- typename MaskType::Pointer movingMask=NULL;
- if (m_ArgsInfo.targetMask_given)
- {
- movingMask= MaskType::New();
- typedef itk::Image< unsigned char, ImageDimension > ImageMaskType;
- typedef itk::ImageFileReader< ImageMaskType > MaskReaderType;
- typename MaskReaderType::Pointer maskReader = MaskReaderType::New();
- maskReader->SetFileName(m_ArgsInfo.targetMask_arg);
- try
- {
- maskReader->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught !" << std::endl;
- std::cerr << err << std::endl;
- }
- if (m_Verbose)std::cout <<"Target image mask was read..." <<std::endl;
-
- movingMask->SetImage( maskReader->GetOutput() );
- }
-
-
- //=======================================================
- // Output Regions
- //=======================================================
-
- if (m_Verbose)
- {
- // Fixed image region
- std::cout<<"The fixed image has its origin at "<<fixedImage->GetOrigin()<<std::endl
- <<"The fixed image region starts at index "<<fixedImageRegion.GetIndex()<<std::endl
- <<"The fixed image region has size "<< fixedImageRegion.GetSize()<<std::endl;
-
- // Transform region
- std::cout<<"The transform has its origin at "<<transformRegionOrigin<<std::endl
- <<"The transform region will start at index "<<transformRegion.GetIndex()<<std::endl
- <<"The transform region has size "<< transformRegion.GetSize()<<std::endl;
-
- // Metric region
- std::cout<<"The metric region has its origin at "<<metricRegionOrigin<<std::endl
- <<"The metric region will start at index "<<metricRegion.GetIndex()<<std::endl
- <<"The metric region has size "<< metricRegion.GetSize()<<std::endl;
-
- }
-
-
- //=======================================================
- // Pyramids (update them for transform initializer)
- //=======================================================
- typedef clitk::RecursiveSpatioTemporalMultiResolutionPyramidImageFilter< FixedImageType, FixedImageType> FixedImagePyramidType;
- typedef clitk::RecursiveSpatioTemporalMultiResolutionPyramidImageFilter< MovingImageType, MovingImageType> MovingImagePyramidType;
- typename FixedImagePyramidType::Pointer fixedImagePyramid = FixedImagePyramidType::New();
- typename MovingImagePyramidType::Pointer movingImagePyramid = MovingImagePyramidType::New();
- fixedImagePyramid->SetUseShrinkImageFilter(false);
- fixedImagePyramid->SetInput(croppedFixedImage);
- fixedImagePyramid->SetNumberOfLevels(m_ArgsInfo.levels_arg);
- movingImagePyramid->SetUseShrinkImageFilter(false);
- movingImagePyramid->SetInput(movingImage);
- movingImagePyramid->SetNumberOfLevels(m_ArgsInfo.levels_arg);
- if (m_Verbose) std::cout<<"Creating the image pyramid..."<<std::endl;
- fixedImagePyramid->Update();
- movingImagePyramid->Update();
- typedef clitk::MultiResolutionPyramidRegionFilter<FixedImageType> FixedImageRegionPyramidType;
- typename FixedImageRegionPyramidType::Pointer fixedImageRegionPyramid=FixedImageRegionPyramidType::New();
- fixedImageRegionPyramid->SetRegion(metricRegion);
- fixedImageRegionPyramid->SetSchedule(fixedImagePyramid->GetSchedule());
-
-
-
-
- // //=======================================================
- // // Rigid Transform
- // //=======================================================
- // typedef itk::Euler3DTransform <double> RigidTransformType;
- // RigidTransformType::Pointer rigidTransform;
- // if (m_ArgsInfo.rigid_given)
- // {
- // rigidTransform=RigidTransformType::New();
- // itk::Matrix<double,4,4> rigidTransformMatrix=clitk::ReadMatrix3D(m_ArgsInfo.rigid_arg);
-
- // //Set the rotation
- // itk::Matrix<double,3,3> finalRotation = clitk::GetRotationalPartMatrix3D(rigidTransformMatrix);
- // rigidTransform->SetMatrix(finalRotation);
-
- // //Set the translation
- // itk::Vector<double,3> finalTranslation = clitk::GetTranslationPartMatrix3D(rigidTransformMatrix);
- // rigidTransform->SetTranslation(finalTranslation);
-
- // }
-
-
- //=======================================================
- // ShapedBSplineSpatioTemporal Transform
- //=======================================================
- typedef clitk::ShapedBLUTSpatioTemporalDeformableTransform<TCoordRep,ImageDimension, ImageDimension > TransformType;
- typename TransformType::Pointer transform= TransformType::New();
- transform->SetTransformShape(m_ArgsInfo.shape_arg);
- if (fixedMask) transform->SetMask( fixedMask );
- // if (rigidTransform) transform->SetBulkTransform( rigidTransform );
-
- //-------------------------------------------------------------------------
- // The transform initializer
- //-------------------------------------------------------------------------
- typedef clitk::ShapedBLUTSpatioTemporalDeformableTransformInitializer< TransformType,FixedImageType> InitializerType;
- typename InitializerType::Pointer initializer = InitializerType::New();
- initializer->SetVerbose(m_Verbose);
- initializer->SetImage(fixedImagePyramid->GetOutput(0));
- initializer->SetTransform(transform);
-
- //-------------------------------------------------------------------------
- // Order
- //-------------------------------------------------------------------------
- typename FixedImageType::RegionType::SizeType splineOrders ;
- splineOrders.Fill(3);
- if (m_ArgsInfo.order_given)
- for(unsigned int i=0; i<ImageDimension;i++)
- splineOrders[i]=m_ArgsInfo.order_arg[i];
- if (m_Verbose) std::cout<<"Setting the spline orders to "<<splineOrders<<"..."<<std::endl;
- initializer->SetSplineOrders(splineOrders);
-
- //-------------------------------------------------------------------------
- // Levels
- //-------------------------------------------------------------------------
-
- // Spacing
- if (m_ArgsInfo.spacing_given)
- {
- initializer->m_ControlPointSpacingArray.resize(m_ArgsInfo.levels_arg);
- initializer->SetControlPointSpacing(m_ArgsInfo.spacing_arg);
- initializer->m_ControlPointSpacingArray[m_ArgsInfo.levels_arg-1]=initializer->m_ControlPointSpacing;
- if (m_Verbose) std::cout<<"Using a control point spacing of "<<initializer->m_ControlPointSpacingArray[m_ArgsInfo.levels_arg-1]
- <<" at level "<<m_ArgsInfo.levels_arg<<" of "<<m_ArgsInfo.levels_arg<<"..."<<std::endl;
-
- for (int i=1; i<m_ArgsInfo.levels_arg; i++ )
- {
- initializer->m_ControlPointSpacingArray[m_ArgsInfo.levels_arg-1-i]=initializer->m_ControlPointSpacingArray[m_ArgsInfo.levels_arg-i]*2;
- initializer->m_ControlPointSpacingArray[m_ArgsInfo.levels_arg-1-i][ImageDimension-1]=2;
- if (m_Verbose) std::cout<<"Using a control point spacing of "<<initializer->m_ControlPointSpacingArray[m_ArgsInfo.levels_arg-1-i]
- <<" at level "<<m_ArgsInfo.levels_arg-i<<" of "<<m_ArgsInfo.levels_arg<<"..."<<std::endl;
- }
-
- }
-
- // Control
- if (m_ArgsInfo.control_given)
- {
- initializer->m_NumberOfControlPointsInsideTheImageArray.resize(m_ArgsInfo.levels_arg);
- initializer->SetNumberOfControlPointsInsideTheImage(m_ArgsInfo.control_arg);
- initializer->m_NumberOfControlPointsInsideTheImageArray[m_ArgsInfo.levels_arg-1]=initializer->m_NumberOfControlPointsInsideTheImage;
- if (m_Verbose) std::cout<<"Using "<< initializer->m_NumberOfControlPointsInsideTheImageArray[m_ArgsInfo.levels_arg-1]<<"control points inside the image"
- <<" at level "<<m_ArgsInfo.levels_arg<<" of "<<m_ArgsInfo.levels_arg<<"..."<<std::endl;
-
- for (int i=1; i<m_ArgsInfo.levels_arg; i++ )
- {
- for(unsigned int j=0;j<ImageDimension-1;j++)
- initializer->m_NumberOfControlPointsInsideTheImageArray[m_ArgsInfo.levels_arg-1-i][j]=ceil ((double)initializer->m_NumberOfControlPointsInsideTheImageArray[m_ArgsInfo.levels_arg-i][j]/2.);
- // initializer->m_NumberOfControlPointsInsideTheImageArray[m_ArgsInfo.levels_arg-1-i]=ceil ((double)initializer->m_NumberOfControlPointsInsideTheImageArray[m_ArgsInfo.levels_arg-i]/2.);
- if (m_Verbose) std::cout<<"Using "<< initializer->m_NumberOfControlPointsInsideTheImageArray[m_ArgsInfo.levels_arg-1-i]<<"control points inside the image"
- <<" at level "<<m_ArgsInfo.levels_arg<<" of "<<m_ArgsInfo.levels_arg<<"..."<<std::endl;
-
- }
- }
-
- // Inialize on the first level
- if (m_ArgsInfo.verbose_flag) std::cout<<"Initializing transform for level 1 of "<<m_ArgsInfo.levels_arg<<"..."<<std::endl;
- if (m_ArgsInfo.spacing_given) initializer->SetControlPointSpacing( initializer->m_ControlPointSpacingArray[0]);
- if (m_ArgsInfo.control_given) initializer->SetNumberOfControlPointsInsideTheImage(initializer->m_NumberOfControlPointsInsideTheImageArray[0]);
- if (m_ArgsInfo.samplingFactor_given) initializer->SetSamplingFactors(m_ArgsInfo.samplingFactor_arg);
-
- // Initialize
- initializer->InitializeTransform();
-
- //-------------------------------------------------------------------------
- // Initial parameters (passed by reference)
- //-------------------------------------------------------------------------
- typedef typename TransformType::ParametersType ParametersType;
- const unsigned int numberOfParameters = transform->GetNumberOfParameters();
- ParametersType parameters(numberOfParameters);
- parameters.Fill( 0.0 );
- transform->SetParameters( parameters );
- if (m_ArgsInfo.initCoeff_given) initializer->SetInitialParameters(m_ArgsInfo.initCoeff_arg, parameters);
-
-
- //=======================================================
- // Interpolator
- //=======================================================
- typedef clitk::GenericInterpolator<args_info_clitkShapedBLUTSpatioTemporalDIR, FixedImageType,TCoordRep > GenericInterpolatorType;
- typename GenericInterpolatorType::Pointer genericInterpolator=GenericInterpolatorType::New();
- genericInterpolator->SetArgsInfo(m_ArgsInfo);
- typedef itk::InterpolateImageFunction< FixedImageType, TCoordRep > InterpolatorType;
- typename InterpolatorType::Pointer interpolator=genericInterpolator->GetInterpolatorPointer();
-
-
- //=======================================================
- // Metric
- //=======================================================
- typedef clitk::GenericMetric< args_info_clitkShapedBLUTSpatioTemporalDIR, FixedImageType,MovingImageType > GenericMetricType;
- typename GenericMetricType::Pointer genericMetric=GenericMetricType::New();
- genericMetric->SetArgsInfo(m_ArgsInfo);
- genericMetric->SetFixedImage(fixedImagePyramid->GetOutput(0));
- if (fixedMask) genericMetric->SetFixedImageMask(fixedMask);
- genericMetric->SetFixedImageRegion(fixedImageRegionPyramid->GetOutput(0));
- typedef itk::ImageToImageMetric< FixedImageType, MovingImageType > MetricType;
- typename MetricType::Pointer metric=genericMetric->GetMetricPointer();
- if (movingMask) metric->SetMovingImageMask(movingMask);
-
-#if defined(ITK_USE_OPTIMIZED_REGISTRATION_METHODS) || ITK_VERSION_MAJOR >= 4
- if (threadsGiven) metric->SetNumberOfThreads( threads );
-#else
- if (m_Verbose) std::cout<<"Not setting the number of threads (not compiled with USE_OPTIMIZED_REGISTRATION_METHODS)..."<<std::endl;
-#endif
-
-
- //=======================================================
- // Optimizer
- //=======================================================
- typedef clitk::GenericOptimizer<args_info_clitkShapedBLUTSpatioTemporalDIR> GenericOptimizerType;
- GenericOptimizerType::Pointer genericOptimizer = GenericOptimizerType::New();
- genericOptimizer->SetArgsInfo(m_ArgsInfo);
- genericOptimizer->SetMaximize(genericMetric->GetMaximize());
- genericOptimizer->SetNumberOfParameters(transform->GetNumberOfParameters());
- typedef itk::SingleValuedNonLinearOptimizer OptimizerType;
- OptimizerType::Pointer optimizer = genericOptimizer->GetOptimizerPointer();
-
-
- //=======================================================
- // Registration
- //=======================================================
- typedef clitk::SpatioTemporalMultiResolutionImageRegistrationMethod< FixedImageType, MovingImageType > RegistrationType;
- typename RegistrationType::Pointer registration = RegistrationType::New();
- registration->SetMetric( metric );
- registration->SetOptimizer( optimizer );
- registration->SetInterpolator( interpolator );
- registration->SetTransform (transform);
- if(threadsGiven) registration->SetNumberOfThreads(threads);
- registration->SetFixedImage( croppedFixedImage );
- registration->SetMovingImage( movingImage );
- registration->SetFixedImageRegion( metricRegion );
- registration->SetFixedImagePyramid( fixedImagePyramid );
- registration->SetMovingImagePyramid( movingImagePyramid );
- registration->SetInitialTransformParameters( transform->GetParameters() );
- registration->SetNumberOfLevels( m_ArgsInfo.levels_arg );
- if (m_Verbose) std::cout<<"Setting the number of resolution levels to "<<m_ArgsInfo.levels_arg<<"..."<<std::endl;
-
-
- //================================================================================================
- // Observers
- //================================================================================================
- if (m_Verbose)
- {
- // Output iteration info
- typedef CommandIterationUpdate <RegistrationType,args_info_clitkShapedBLUTSpatioTemporalDIR> CommandIterationUpdateType;
- typename CommandIterationUpdateType::Pointer observer = CommandIterationUpdateType::New();
- observer->SetInitializer(initializer);
- observer->SetArgsInfo(m_ArgsInfo);
- observer->SetOptimizer(genericOptimizer);
- optimizer->AddObserver( itk::IterationEvent(), observer );
-
- // Output level info
- typedef RegistrationInterfaceCommand<RegistrationType,args_info_clitkShapedBLUTSpatioTemporalDIR> CommandType;
- typename CommandType::Pointer command = CommandType::New();
- command->SetInitializer(initializer);
- command->SetArgsInfo(m_ArgsInfo);
- command->SetCommandIterationUpdate(observer);
- command->SetMaximize(genericMetric->GetMaximize());
- command->SetMetricRegion(metricRegion);
- registration->AddObserver( itk::IterationEvent(), command );
- }
-
-
- //=======================================================
- // Let's go
- //=======================================================
- if (m_Verbose) std::cout << std::endl << "Starting Registration" << std::endl;
-
- try
- {
- registration->StartRegistration();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught while registering!" << std::endl;
- std::cerr << err << std::endl;
- return;
- }
-
-
- //=======================================================
- // Get the result
- //=======================================================
- OptimizerType::ParametersType finalParameters = registration->GetLastTransformParameters();
- transform->SetParameters( finalParameters );
- if (m_Verbose)
- {
- std::cout<<"Stop condition description: "
- <<registration->GetOptimizer()->GetStopConditionDescription()<<std::endl;
- }
-
-
- //=======================================================
- // Get the BSplineSpatioTemporal coefficient images and write them
- //=======================================================
- if (m_ArgsInfo.coeff_given)
- {
- typedef typename TransformType::CoefficientImageType CoefficientImageType;
- typename CoefficientImageType::Pointer coefficientImage =transform->GetCoefficientImage();
- typedef itk::ImageFileWriter<CoefficientImageType> CoeffWriterType;
- typename CoeffWriterType::Pointer coeffWriter=CoeffWriterType::New();
- coeffWriter->SetInput(coefficientImage);
- coeffWriter->SetFileName(m_ArgsInfo.coeff_arg);
- coeffWriter->Update();
-
- }
- if (m_ArgsInfo.padCoeff_given)
- {
- typedef itk::Image<itk::Vector<TCoordRep, SpaceDimension>, ImageDimension> CoefficientImageType;
- typename CoefficientImageType::Pointer coefficientImage =transform->GetPaddedCoefficientImage();
- typedef itk::ImageFileWriter<CoefficientImageType> CoeffWriterType;
- typename CoeffWriterType::Pointer coeffWriter=CoeffWriterType::New();
- coeffWriter->SetInput(coefficientImage);
- coeffWriter->SetFileName(m_ArgsInfo.padCoeff_arg);
- coeffWriter->Update();
- }
-
-
- //=======================================================
- // Generate the DVF (4D with 3 comps and 4D with 4 comps)
- //=======================================================
- typedef itk::Vector< float, SpaceDimension > DisplacementType;
- typedef itk::Vector< float, ImageDimension > Displacement4DType;
- typedef itk::Image< DisplacementType, ImageDimension > DeformationFieldType;
- typedef itk::Image< Displacement4DType, ImageDimension > DeformationField4DType;
-
- typename DeformationFieldType::Pointer field = DeformationFieldType::New();
- typename DeformationField4DType::Pointer field4D = DeformationField4DType::New();
- field->SetRegions( fixedImageRegion );
- field->SetOrigin( fixedImage->GetOrigin() );
- field->SetSpacing( fixedImage->GetSpacing() );
- field->SetDirection( fixedImage->GetDirection() );
- field->Allocate();
- field4D->SetRegions( fixedImageRegion );
- field4D->SetOrigin( fixedImage->GetOrigin() );
- field4D->SetSpacing( fixedImage->GetSpacing() );
- field4D->SetDirection( fixedImage->GetDirection() );
- field4D->Allocate();
-
- typedef itk::ImageRegionIteratorWithIndex< DeformationFieldType > FieldIterator;
- typedef itk::ImageRegionIteratorWithIndex< DeformationField4DType > Field4DIterator;
- FieldIterator fi( field, fixedImageRegion );
- Field4DIterator fi4D( field4D, fixedImageRegion );
- fi.GoToBegin();
- fi4D.GoToBegin();
-
- typename TransformType::InputPointType fixedPoint;
- typename TransformType::OutputPointType movingPoint;
- typename DeformationFieldType::IndexType index;
-
- DisplacementType displacement;
- Displacement4DType displacement4D;
- displacement4D[ImageDimension-1]=0;
- while( ! fi.IsAtEnd() )
- {
- index = fi.GetIndex();
- field->TransformIndexToPhysicalPoint( index, fixedPoint );
- movingPoint = transform->TransformPoint( fixedPoint );
- for (unsigned int i=0; i<SpaceDimension; i++)
- {
- displacement[i] = movingPoint[i] - fixedPoint[i];
- displacement4D[i] = movingPoint[i] - fixedPoint[i];
- }
- fi.Set( displacement );
- fi4D.Set(displacement4D);
- ++fi;
- ++fi4D;
- }
-
-
- //=======================================================
- // Write the DVF
- //=======================================================
- typedef itk::ImageFileWriter< DeformationFieldType > FieldWriterType;
- typename FieldWriterType::Pointer fieldWriter = FieldWriterType::New();
- fieldWriter->SetFileName( m_ArgsInfo.vf_arg );
- fieldWriter->SetInput( field );
- try
- {
- fieldWriter->Update();
- }
- catch( itk::ExceptionObject & excp )
- {
- std::cerr << "Exception thrown writing the DVF" << std::endl;
- std::cerr << excp << std::endl;
- return;
- }
-
-
- //=======================================================
- // Resample the moving image
- //=======================================================
- typedef itk::WarpImageFilter< MovingImageType, FixedImageType, DeformationField4DType > WarpFilterType;
- typename WarpFilterType::Pointer warp = WarpFilterType::New();
-
-#if ITK_VERSION_MAJOR >= 4
- warp->SetDisplacementField( field4D );
-#else
- warp->SetDeformationField( field4D );
-#endif
- warp->SetInput( movingImageReader->GetOutput() );
- warp->SetOutputOrigin( fixedImage->GetOrigin() );
- warp->SetOutputSpacing( fixedImage->GetSpacing() );
- warp->SetOutputDirection( fixedImage->GetDirection() );
- warp->SetEdgePaddingValue( 0.0 );
- warp->Update();
-
-
- //=======================================================
- // Write the warped image
- //=======================================================
- typedef itk::ImageFileWriter< FixedImageType > WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName( m_ArgsInfo.output_arg );
- writer->SetInput( warp->GetOutput() );
-
- try
- {
- writer->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught !" << std::endl;
- std::cerr << err << std::endl;
- return;
- }
-
-
- //=======================================================
- // Calculate the difference after the deformable transform
- //=======================================================
- typedef clitk::DifferenceImageFilter< FixedImageType, FixedImageType> DifferenceFilterType;
- if (m_ArgsInfo.after_given)
- {
- typename DifferenceFilterType::Pointer difference = DifferenceFilterType::New();
- difference->SetValidInput( fixedImage );
- difference->SetTestInput( warp->GetOutput() );
-
- try
- {
- difference->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught calculating the difference !" << std::endl;
- std::cerr << err << std::endl;
- return;
- }
-
- typename WriterType::Pointer differenceWriter=WriterType::New();
- differenceWriter->SetInput(difference->GetOutput());
- differenceWriter->SetFileName(m_ArgsInfo.after_arg);
- differenceWriter->Update();
-
- }
-
-
- //=======================================================
- // Calculate the difference before the deformable transform
- //=======================================================
- if( m_ArgsInfo.before_given )
- {
-
- typename FixedImageType::Pointer moving=FixedImageType::New();
- if (m_ArgsInfo.rigid_given)
- {
- typedef itk::ResampleImageFilter<MovingImageType, FixedImageType> ResamplerType;
- typename ResamplerType::Pointer resampler=ResamplerType::New();
- resampler->SetInput(movingImage);
- resampler->SetOutputOrigin(fixedImage->GetOrigin());
- resampler->SetSize(fixedImage->GetLargestPossibleRegion().GetSize());
- resampler->SetOutputSpacing(fixedImage->GetSpacing());
- resampler->SetDefaultPixelValue( 0. );
- //resampler->SetTransform(rigidTransform);
- resampler->Update();
- moving=resampler->GetOutput();
- }
- else
- moving=movingImage;
-
- typename DifferenceFilterType::Pointer difference = DifferenceFilterType::New();
- difference->SetValidInput( fixedImage );
- difference->SetTestInput( moving );
-
- try
- {
- difference->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught calculating the difference !" << std::endl;
- std::cerr << err << std::endl;
- return;
- }
-
- typename WriterType::Pointer differenceWriter=WriterType::New();
- writer->SetFileName( m_ArgsInfo.before_arg );
- writer->SetInput( difference->GetOutput() );
- writer->Update( );
- }
-
- return;
-
- }
-}//end clitk
-
-#endif //#define clitkShapedBLUTSpatioTemporalDIRGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkCalculateDistanceMapGenericFilter.txx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkCalculateDistanceMap_ggo.h"
-#include "clitkIO.h"
-#include "clitkCalculateDistanceMapGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkCalculateDistanceMap, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::CalculateDistanceMapGenericFilter::Pointer genericFilter=clitk::CalculateDistanceMapGenericFilter::New();
- genericFilter->SetArgsInfo(args_info);
-
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkCalculateDistanceMap.ggo
-package "clitkCalculateDistanceMap"
-version "1.0"
-purpose "Calculate the distance map(float) of a binary image: Signed Danielsson Distance Map filter or Fast Marching filter"
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "invert" - "Set inside instead of outside to positive" flag off
-option "fastMarching" - "Use the fast marching filter" flag off
-
+++ /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://www.centreleonberard.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 clitkCalculateDistanceMapGenericFilter_cxx
-#define clitkCalculateDistanceMapGenericFilter_cxx
-
-/* =================================================
- * @file clitkCalculateDistanceMapGenericFilter.cxx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkCalculateDistanceMapGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- CalculateDistanceMapGenericFilter::CalculateDistanceMapGenericFilter()
- {
- m_Verbose=false;
- }
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void CalculateDistanceMapGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_ArgsInfo.input_arg, Dimension, PixelType);
-
- // Call UpdateWithDim()
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- // else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkCalculateDistanceMapGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkCalculateDistanceMapGenericFilter_h
-#define clitkCalculateDistanceMapGenericFilter_h
-
-/* =================================================
- * @file clitkCalculateDistanceMapGenericFilter.h
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkCalculateDistanceMap_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkSignedDanielssonDistanceMapImageFilter.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT CalculateDistanceMapGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef CalculateDistanceMapGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( CalculateDistanceMapGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkCalculateDistanceMap & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- CalculateDistanceMapGenericFilter();
- ~CalculateDistanceMapGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- bool m_Verbose;
- args_info_clitkCalculateDistanceMap m_ArgsInfo;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkCalculateDistanceMapGenericFilter.txx"
-#endif
-
-#endif // #define clitkCalculateDistanceMapGenericFilter_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://www.centreleonberard.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 clitkCalculateDistanceMapGenericFilter_txx
-#define clitkCalculateDistanceMapGenericFilter_txx
-
-/* =================================================
- * @file clitkCalculateDistanceMapGenericFilter.txx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- CalculateDistanceMapGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- CalculateDistanceMapGenericFilter::UpdateWithDimAndPixelType()
- {
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<float, Dimension> OutputImageType; //needs to be floating point
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_ArgsInfo.input_arg);
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // The fastMarching filter
- typename OutputImageType::Pointer output;
- if (m_ArgsInfo.fastMarching_flag)
- {
-// typedef itk::FastMarchingImageFilter< OutputImageType, OutputImageType > FastMarchingFilterType;
-// FastMarchingFilterType::Pointer fastMarchingFilter=FastMarchingFilterType::New();
-// fastMarchingFilter->
- }
-
- // The signed Distance map filter
- else
- {
- typedef itk::SignedDanielssonDistanceMapImageFilter<InputImageType, OutputImageType> DistanceMapImageFilterType;
- typename DistanceMapImageFilterType::Pointer distanceMapImageFilter = DistanceMapImageFilterType::New();
- distanceMapImageFilter->SetInput(input);
- distanceMapImageFilter->SetInsideIsPositive(m_ArgsInfo.invert_flag);
- distanceMapImageFilter->Update();
- output=distanceMapImageFilter->GetOutput();
- }
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkCalculateDistanceMapGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkFillImageRegion.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkFillImageRegion_ggo.h"
-#include "clitkIO.h"
-#include "clitkFillImageRegionGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkFillImageRegion, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::FillImageRegionGenericFilter::Pointer genericFilter=clitk::FillImageRegionGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkFillImageRegion.ggo
-package "clitkFillImageRegion"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "shape" s "Region shape: 0=rectangular, 1=ellipsoide" int no default="0"
-option "size" - "Rectangular: size of the region (voxels)" int no multiple default="10"
-option "index" - "Rectangular: start index of the region (voxels)" int no multiple default="0"
-option "center" c "Ellipsoide: center of the ellips (mm, defaults to the middle of the image)" double no multiple
-option "offset" - "Ellipsoide: offset of the middle of the ellips wrt center (mm)" double no multiple
-option "axes" a "Half axes of ellips (mm)" double no multiple default="10.0"
-option "value" p "Padding value for the region" double no default="0.0"
+++ /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://www.centreleonberard.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 clitkFillImageRegionGenericFilter_cxx
-#define clitkFillImageRegionGenericFilter_cxx
-
-/* =================================================
- * @file clitkFillImageRegionGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkFillImageRegionGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- FillImageRegionGenericFilter::FillImageRegionGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void FillImageRegionGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- // else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkFillImageRegionGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkFillImageRegionGenericFilter_h
-#define clitkFillImageRegionGenericFilter_h
-
-/* =================================================
- * @file clitkFillImageRegionGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkFillImageRegion_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkImageRegionIterator.h"
-#include "itkImageRegionIteratorWithIndex.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT FillImageRegionGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef FillImageRegionGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( FillImageRegionGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkFillImageRegion & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- FillImageRegionGenericFilter();
- ~FillImageRegionGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkFillImageRegion m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkFillImageRegionGenericFilter.txx"
-#endif
-
-#endif // #define clitkFillImageRegionGenericFilter_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://www.centreleonberard.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 clitkFillImageRegionGenericFilter_txx
-#define clitkFillImageRegionGenericFilter_txx
-
-/* =================================================
- * @file clitkFillImageRegionGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- FillImageRegionGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- FillImageRegionGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Processing
- switch(m_ArgsInfo.shape_arg)
- {
- //rectangular
- case 0:
- {
- // Get Size and index of the region
- typename InputImageType::SizeType size;
- if (m_ArgsInfo.size_given)
- for(unsigned int i=0; i<Dimension; i++)
- size[i]=m_ArgsInfo.size_arg[i];
- else
- size.Fill(m_ArgsInfo.size_arg[0]);
-
- // Get Index of the region
- typename InputImageType::IndexType index;
- if (m_ArgsInfo.index_given)
- for(unsigned int i=0; i<Dimension; i++)
- index[i]=m_ArgsInfo.index_arg[i];
- else
- index.Fill(m_ArgsInfo.index_arg[0]);
-
- // Set the region
- typename InputImageType::RegionType region;
- region.SetIndex(index);
- region.SetSize(size);
-
- // Iterator
- typedef itk::ImageRegionIterator<InputImageType> IteratorType;
- IteratorType it(input, region);
- it.GoToBegin();
- while (!it.IsAtEnd()) {
- it.Set(m_ArgsInfo.value_arg);
- ++it;
- }
-
- break;
- }
-
- //ellipsoide
- case 1:
- {
-
- //Get the center
- typename InputImageType::PointType center;
- if (m_ArgsInfo.center_given)
- for(unsigned int i=0; i<Dimension; i++)
- center[i]=m_ArgsInfo.center_arg[i];
- else
- {
- typename InputImageType::SizeType size= input->GetLargestPossibleRegion().GetSize();
- typename InputImageType::SpacingType spacing= input->GetSpacing();
- typename InputImageType::PointType origin= input->GetOrigin();
- for (unsigned int i=0; i<Dimension; i++)
- center[i]=origin[i]+(double)size[i]/2*spacing[i];
- }
- if (m_ArgsInfo.offset_given)
- {
- typename itk::Vector<double, Dimension> offset;
- for (unsigned int i=0; i<Dimension; i++)
- center[i]+=m_ArgsInfo.offset_arg[i];
- }
-
-
- // Get the half axes size
- typename itk::Vector<double, Dimension> axes;
- if (m_ArgsInfo.axes_given)
- for(unsigned int i=0; i<Dimension; i++)
- axes[i]=m_ArgsInfo.axes_arg[i];
- else
- axes.Fill(m_ArgsInfo.axes_arg[0]);
-
-
- // Build iterator
- typedef itk::ImageRegionIteratorWithIndex<InputImageType> IteratorType;
- IteratorType it(input, input->GetLargestPossibleRegion());
- it.GoToBegin();
-
- typename InputImageType::PointType point;
- typename InputImageType::IndexType index;
- double distance;
-
- while (!it.IsAtEnd())
- {
- index=it.GetIndex();
- input->TransformIndexToPhysicalPoint(index, point);
- distance=0.0;
- for(unsigned int i=0; i<Dimension; i++)
- distance+=powf( ( (center[i]-point[i])/axes[i] ), 2);
-
- if (distance<1)
- it.Set(m_ArgsInfo.value_arg);
- ++it;
- }
- break;
- }
- }
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(input);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkFillImageRegionGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================*/
-/*------------------------------------------------------------------------
-
- Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
- l'Image). All rights reserved. See Doc/License.txt or
- http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
-
- This software is distributed WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE. See the above copyright notices for more information.
-
- ------------------------------------------------------------------------*/
-
-// clitk
-#include "clitkFillMask_ggo.h"
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkFillMaskGenericFilter.h"
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkFillMask,args_info);
- CLITK_INIT;
-
- // Filter
- typedef clitk::FillMaskGenericFilter<args_info_clitkFillMask> FilterType;
- FilterType::Pointer filter = FilterType::New();
-
- filter->SetArgsInfo(args_info);
-
- try {
- filter->Update();
- } catch(std::runtime_error e) {
- std::cerr << e.what() << std::endl;
- }
-
- return EXIT_SUCCESS;
-} // This is the end, my friend
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkFillMask.ggo
-package "clitkFillMask"
-version "1.0"
-purpose "Fill in holes (bg=0) in an object (fg=1) of a binary image, by running over the slices and retaining only one connected component bg."
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "dir" d "Directions (axes) to perform filling (defaults to 2,1,0)" int multiple no
-
-
+++ /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://www.centreleonberard.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 clitkFillMaskGenericFilter_cxx
-#define clitkFillMaskGenericFilter_cxx
-
-/* =================================================
- * @file clitkFillMaskGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkFillMaskGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- FillMaskGenericFilter::FillMaskGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void FillMaskGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithPixelType
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
- if (Dimension != 3)
- {
- std::cerr<<"Error: Only for 3D!!"<<std::endl;
- return;
- }
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithPixelType<signed short>();
- }
-
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithPixelType<unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithPixelType<unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithPixelType<signed char>();
- // }
-
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithPixelType<float>();
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkFillMaskGenericFilter_cxx
+++ /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://www.centreleonberard.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 CLITKFILLMASKGENERICFILTER_H
-#define CLITKFILLMASKGENERICFILTER_H
-
-// clitk
-#include "clitkImageToImageGenericFilter.h"
-#include "clitkFillMaskFilter.h"
-
-//--------------------------------------------------------------------
-namespace clitk
-{
-
- template<class ArgsInfoType>
- class ITK_EXPORT FillMaskGenericFilter :
- public ImageToImageGenericFilter<FillMaskGenericFilter<ArgsInfoType> >
- {
- public:
- //--------------------------------------------------------------------
- FillMaskGenericFilter();
-
- //--------------------------------------------------------------------
- typedef FillMaskGenericFilter Self;
- typedef ImageToImageGenericFilter<Self > Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- //--------------------------------------------------------------------
- itkNewMacro(Self);
- itkTypeMacro(FillMaskGenericFilter, LightObject);
-
- //--------------------------------------------------------------------
- void SetArgsInfo(const ArgsInfoType & a);
-
- //--------------------------------------------------------------------
- // Main function called each time the filter is updated
- template<class ImageType>
- void UpdateWithInputImageType();
-
- protected:
- template<unsigned int Dim> void InitializeImageType();
- ArgsInfoType mArgsInfo;
- }; // end class
- //--------------------------------------------------------------------
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkFillMaskGenericFilter.txx"
-#endif
-
-#endif // #define CLITKFILLMASKGENERICFILTER_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://www.centreleonberard.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 CLITKFILLMASKGENERICFILTER_TXX
-#define CLITKFILLMASKGENERICFILTER_TXX
-
-#include "clitkImageCommon.h"
-
-//--------------------------------------------------------------------
-template<class ArgsInfoType>
-clitk::FillMaskGenericFilter<ArgsInfoType>::FillMaskGenericFilter():
- ImageToImageGenericFilter<Self>("FillMask")
-{
- this->SetFilterBase(NULL);
- InitializeImageType<3>();
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template<class ArgsInfoType>
-template<unsigned int Dim>
-void clitk::FillMaskGenericFilter<ArgsInfoType>::InitializeImageType()
-{
- ADD_IMAGE_TYPE(Dim, uchar);
- ADD_IMAGE_TYPE(Dim, short);
- // ADD_IMAGE_TYPE(Dim, int);
- // ADD_IMAGE_TYPE(Dim, float);
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template<class ArgsInfoType>
-void clitk::FillMaskGenericFilter<ArgsInfoType>::SetArgsInfo(const ArgsInfoType & a)
-{
- mArgsInfo=a;
- SetIOVerbose(mArgsInfo.verbose_flag);
- // if (mArgsInfo.imagetypes_flag) this->PrintAvailableImageTypes();
- if (mArgsInfo.input_given) AddInputFilename(mArgsInfo.input_arg);
- if (mArgsInfo.output_given) AddOutputFilename(mArgsInfo.output_arg);
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-// Update with the number of dimensions and the pixeltype
-//--------------------------------------------------------------------
-template<class ArgsInfoType>
-template<class ImageType>
-void clitk::FillMaskGenericFilter<ArgsInfoType>::UpdateWithInputImageType()
-{
- // Reading input
- typename ImageType::Pointer input = this->template GetInput<ImageType>(0);
-
- // Create filter
- typedef clitk::FillMaskFilter<ImageType> FilterType;
- typename FilterType::Pointer filter = FilterType::New();
-
- // Set Options
- filter->SetInput(input);
- filter->SetOptionsFromArgsInfo(mArgsInfo);
-
- // Go !
- filter->Update();
-
- // Write/Save results
- typename ImageType::Pointer output = filter->GetOutput();
- this->template SetNextOutput<ImageType>(output);
-}
-//--------------------------------------------------------------------
-
-#endif //#define CLITKFILLMASKGENERICFILTER_TXX
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkLevelSetSegmentationGenericFilter.txx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date 25 June 2009
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkLevelSetSegmentation_ggo.h"
-#include "clitkIO.h"
-#include "clitkLevelSetSegmentationGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkLevelSetSegmentation, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::LevelSetSegmentationGenericFilter::Pointer genericFilter=clitk::LevelSetSegmentationGenericFilter::New();
- genericFilter->SetArgsInfo(args_info);
-
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkLevelSetSegmentation.ggo
-package "clitkLevelSetSegmentation"
-version "1.0"
-purpose "Perform a levelset segmentation. Standard preprocessing is available to create the feature image."
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-section "Input/Output"
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "feature" - "Feature image (speed image: 0 at borders)" string no
-
-
-section "Monitoring"
-
-option "monitorIt" - "Write an image every x iterations" int no default="50"
-option "monitorIm" - "Name of the monitoring image" string no
-
-
-section "Levelset parameter"
-
-option "GAC" - "Use Geodesic Active Contours (default)" flag off
-option "levelSet" - "Output the level set image (unthresholded)" string no
-option "propScale" - "Propagation scale" double no default="1.0"
-option "curveScale" - "Curve scale" double no default="1.0"
-option "advectionScale" - "Advection scale" double no default="1.0"
-option "maxRMS" - "Max RMS error" double no default="0.01"
-option "iter" - "Max number of iterations" int no default="10"
-
-
-section "Feature preprocessing"
-
-option "smooth" - "Smooth feature image (Curvature Anisotropic Diffusion)" flag off
-option "timeStep" - "Smoothing: time step" double no default="0.125"
-option "cond" - "Smoothing: conduction" double no default="5"
-option "iterSmooth" - "Smoothing: iterations" int no default="9"
-option "gradMag" - "Calculate gradient magnitude" flag off
-option "gradMagGauss" - "Calculate gradient magnitude using recursive gaussian filter" flag off
-option "sigma" - "Sigma for gaussian" double no default="1.0"
-option "sigmoid" - "Sigmoid function" flag off
-option "alpha" - "Sigmoid: (A+B)/2 (A to be mapped to 0, B to 1)" double no default="1.0"
-option "beta" - "Sigmoid: (B-A)/6<0 (A to be mapped to 0, B to 1)" double no default="0.0"
+++ /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://www.centreleonberard.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 clitkLevelSetSegmentationGenericFilter_cxx
-#define clitkLevelSetSegmentationGenericFilter_cxx
-
-/* =================================================
- * @file clitkLevelSetSegmentationGenericFilter.cxx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkLevelSetSegmentationGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- LevelSetSegmentationGenericFilter::LevelSetSegmentationGenericFilter()
- {
- m_Verbose=false;
- }
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void LevelSetSegmentationGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_ArgsInfo.input_arg, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- // else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkLevelSetSegmentationGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkLevelSetSegmentationGenericFilter_h
-#define clitkLevelSetSegmentationGenericFilter_h
-
-/* =================================================
- * @file clitkLevelSetSegmentationGenericFilter.h
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkLevelSetSegmentation_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkGeodesicActiveContourLevelSetImageFilter.h"
-#include "itkBinaryThresholdImageFilter.h"
-#include "itkCurvatureAnisotropicDiffusionImageFilter.h"
-#include "itkGradientMagnitudeRecursiveGaussianImageFilter.h"
-#include "itkGradientMagnitudeImageFilter.h"
-#include "itkSigmoidImageFilter.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT LevelSetSegmentationGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef LevelSetSegmentationGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( LevelSetSegmentationGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(args_info_clitkLevelSetSegmentation a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- }
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- LevelSetSegmentationGenericFilter();
- ~LevelSetSegmentationGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- bool m_Verbose;
- args_info_clitkLevelSetSegmentation m_ArgsInfo;
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkLevelSetSegmentationGenericFilter.txx"
-#endif
-
-#endif // #define clitkLevelSetSegmentationGenericFilter_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://www.centreleonberard.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 clitkLevelSetSegmentationGenericFilter_txx
-#define clitkLevelSetSegmentationGenericFilter_txx
-
-/* =================================================
- * @file clitkLevelSetSegmentationGenericFilter.txx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- LevelSetSegmentationGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- // if(PixelType == "short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed short>();
- // }
-
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- // else if (PixelType == "unsigned_char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned char>();
- // }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- //else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- // }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- LevelSetSegmentationGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<float, Dimension> InputImageType;
- typedef itk::Image<float, Dimension> FeatureImageType;
- typedef itk::Image<float, Dimension> OutputImageType;
-
- // Read the input (initial level set)
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_ArgsInfo.input_arg);
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Feature image
- typename FeatureImageType::Pointer featureImage;
- if( m_ArgsInfo.feature_given)
- {
- // Read it
- typedef itk::ImageFileReader<FeatureImageType> FeatureReaderType;
- typename FeatureReaderType::Pointer featureReader = FeatureReaderType::New();
- featureReader->SetFileName(m_ArgsInfo.feature_arg);
- featureReader->Update();
- featureImage=featureReader->GetOutput();
-
- // Edge preserving smoothing
- if (m_ArgsInfo.smooth_flag)
- {
- typedef itk::CurvatureAnisotropicDiffusionImageFilter<FeatureImageType, FeatureImageType > SmoothingFilterType;
- typename SmoothingFilterType::Pointer smoothingFilter = SmoothingFilterType::New();
- smoothingFilter->SetInput(featureImage);
- smoothingFilter->SetTimeStep( m_ArgsInfo.timeStep_arg );
- smoothingFilter->SetNumberOfIterations( m_ArgsInfo.iterSmooth_arg );
- smoothingFilter->SetConductanceParameter( m_ArgsInfo.cond_arg );
- smoothingFilter->Update();
- featureImage=smoothingFilter->GetOutput();
-
- }
-
- // Recursive gaussian gradient magnitude
- if (m_ArgsInfo.gradMag_flag)
- {
- typedef itk::GradientMagnitudeImageFilter< FeatureImageType,FeatureImageType> GradientFilterType;
- typename GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();
- gradientMagnitude->SetInput(featureImage);
- gradientMagnitude->Update();
- featureImage=gradientMagnitude->GetOutput();
-
- }
-
- // Recursive gaussian gradient magnitude
- if (m_ArgsInfo.gradMagGauss_flag)
- {
- typedef itk::GradientMagnitudeRecursiveGaussianImageFilter< FeatureImageType,FeatureImageType> GradientFilterType;
- typename GradientFilterType::Pointer gradientMagnitude = GradientFilterType::New();
- gradientMagnitude->SetInput(featureImage);
- gradientMagnitude->SetSigma( m_ArgsInfo.sigma_arg );
- gradientMagnitude->Update();
- featureImage=gradientMagnitude->GetOutput();
- }
-
- // Sigmoid
- if (m_ArgsInfo.sigmoid_flag)
- {
- typedef itk::SigmoidImageFilter<FeatureImageType, FeatureImageType > SigmoidFilterType;
- typename SigmoidFilterType::Pointer sigmoid = SigmoidFilterType::New();
- sigmoid->SetInput(featureImage);
- sigmoid->SetAlpha( m_ArgsInfo.alpha_arg );
- sigmoid->SetBeta( m_ArgsInfo.beta_arg );
- sigmoid->Update();
- featureImage=sigmoid->GetOutput();
- }
-
- }
-
- // Filter
- typename FeatureImageType::Pointer output;
- if (m_ArgsInfo.GAC_flag)
- {
-
- // Create the filter
- typedef itk::GeodesicActiveContourLevelSetImageFilter< InputImageType, FeatureImageType > GeodesicActiveContourFilterType;
- typename GeodesicActiveContourFilterType::Pointer geodesicActiveContour = GeodesicActiveContourFilterType::New();
-
- geodesicActiveContour->SetPropagationScaling( m_ArgsInfo.propScale_arg );
- geodesicActiveContour->SetCurvatureScaling( m_ArgsInfo.curveScale_arg );
- geodesicActiveContour->SetAdvectionScaling( m_ArgsInfo.advectionScale_arg );
- geodesicActiveContour->SetMaximumRMSError( m_ArgsInfo.maxRMS_arg );
- geodesicActiveContour->SetInput( input );
- geodesicActiveContour->SetFeatureImage( featureImage );
- geodesicActiveContour->SetUseImageSpacing(true);
-
- // Monitor
- unsigned int totalNumberOfIterations=0;
- if(m_ArgsInfo.monitorIm_given)
- {
- geodesicActiveContour->SetNumberOfIterations( m_ArgsInfo.monitorIt_arg );
- while (true)
- {
- geodesicActiveContour->Update();
- totalNumberOfIterations+=geodesicActiveContour->GetElapsedIterations();
- if(m_Verbose) std::cout <<"Writing image after "<< totalNumberOfIterations<<"..."<<std::endl;
- writeImage<InputImageType>(geodesicActiveContour->GetOutput(), m_ArgsInfo.monitorIm_arg);
- geodesicActiveContour->SetInput(geodesicActiveContour->GetOutput());
- geodesicActiveContour->SetNumberOfIterations( std::min( (m_ArgsInfo.iter_arg-totalNumberOfIterations) ,(unsigned int) m_ArgsInfo.monitorIt_arg ) );
- if (totalNumberOfIterations> (unsigned int) m_ArgsInfo.iter_arg) break;
- }
- }
- else
- {
- geodesicActiveContour->SetNumberOfIterations( m_ArgsInfo.iter_arg );
- geodesicActiveContour->Update();
- totalNumberOfIterations=geodesicActiveContour->GetElapsedIterations();
- }
-
-
- // Print
- std::cout << std::endl;
- std::cout << "Max. no. iterations: " << m_ArgsInfo.iter_arg << std::endl;
- std::cout << "Max. RMS error: " << geodesicActiveContour->GetMaximumRMSError() << std::endl;
- std::cout << std::endl;
- std::cout << "No. elpased iterations: " << totalNumberOfIterations << std::endl;
- std::cout << "RMS change: " << geodesicActiveContour->GetRMSChange() << std::endl;
-
- output = geodesicActiveContour->GetOutput();
- }
-
- // Write levelset
- if (m_ArgsInfo.levelSet_given)
- {
- typedef itk::ImageFileWriter<FeatureImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.levelSet_arg);
- writer->SetInput(output);
- writer->Update();
- }
-
- // Threshold
- typedef itk::BinaryThresholdImageFilter< FeatureImageType,FeatureImageType > ThresholdingFilterType;
- typename ThresholdingFilterType::Pointer thresholder = ThresholdingFilterType::New();
- thresholder->SetLowerThreshold( -1000.0 );
- thresholder->SetUpperThreshold( 0.0 );
- thresholder->SetOutsideValue( 0 );
- thresholder->SetInsideValue( 1 );
- thresholder->SetInput( output );
- thresholder->Update();
- output=thresholder->GetOutput();
-
- // Output
- typedef itk::ImageFileWriter<FeatureImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkLevelSetSegmentationGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkMorphoReconstruction.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkMorphoReconstruction_ggo.h"
-#include "clitkIO.h"
-#include "clitkMorphoReconstructionGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkMorphoReconstruction, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::MorphoReconstructionGenericFilter::Pointer genericFilter=clitk::MorphoReconstructionGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkMorphoReconstruction.ggo
-package "clitkMorphoReconstruction"
-version "1.0"
-purpose "Morphological reconstruction: restore a marker image by preserving regions and using a mask image. For opening and closing, the mask is the original image."
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-section "I/O"
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-
-
-section "Morpho parameters"
-
-option "type" t "0=Erode, 1=Dilate, 2=Close (erode(dilate(x))), 3=Open (dilate(erode(x)))" int no default="0"
-option "mask" m "0-1: Mask image filename" string no
-option "full" - "2-3: Use full connectivity" flag off
-option "int" - "2-3: Preserve intensities" flag off
-option "radius" r "2-3: Preserve intensities" double no default="1.0"
+++ /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://www.centreleonberard.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 clitkMorphoReconstructionGenericFilter_cxx
-#define clitkMorphoReconstructionGenericFilter_cxx
-
-/* =================================================
- * @file clitkMorphoReconstructionGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkMorphoReconstructionGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- MorphoReconstructionGenericFilter::MorphoReconstructionGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void MorphoReconstructionGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- // else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkMorphoReconstructionGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkMorphoReconstructionGenericFilter_h
-#define clitkMorphoReconstructionGenericFilter_h
-
-/* =================================================
- * @file clitkMorphoReconstructionGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkMorphoReconstruction_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkReconstructionByDilationImageFilter.h"
-#include "itkReconstructionByErosionImageFilter.h"
-#include "itkClosingByReconstructionImageFilter.h"
-#include "itkOpeningByReconstructionImageFilter.h"
-#include "itkBinaryBallStructuringElement.h"
-
-
-namespace clitk
-{
-
-
- class ITK_EXPORT MorphoReconstructionGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef MorphoReconstructionGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( MorphoReconstructionGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkMorphoReconstruction & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- MorphoReconstructionGenericFilter();
- ~MorphoReconstructionGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkMorphoReconstruction m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkMorphoReconstructionGenericFilter.txx"
-#endif
-
-#endif // #define clitkMorphoReconstructionGenericFilter_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://www.centreleonberard.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 clitkMorphoReconstructionGenericFilter_txx
-#define clitkMorphoReconstructionGenericFilter_txx
-
-/* =================================================
- * @file clitkMorphoReconstructionGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- MorphoReconstructionGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- MorphoReconstructionGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Read the mask
- typename InputImageType::Pointer mask;
- if (m_ArgsInfo.mask_given)
- {
- typename InputReaderType::Pointer maskReader=InputReaderType::New();
- maskReader->SetFileName(m_ArgsInfo.mask_arg);
- maskReader->Update();
- mask=maskReader->GetOutput();
- }
-
-
- //---------------------------------
- // Find the type of action
- //---------------------------------
- typedef itk::ImageToImageFilter<InputImageType, InputImageType> ImageFilterType;
- typename ImageFilterType::Pointer filter;
-
- typedef itk::BinaryBallStructuringElement<PixelType, Dimension > KernelType;
- KernelType structuringElement;
- structuringElement.SetRadius(m_ArgsInfo.radius_arg);
- structuringElement.CreateStructuringElement();
-
-
- switch(m_ArgsInfo.type_arg)
- {
-
- case 0:
- {
- typedef itk::ReconstructionByErosionImageFilter<InputImageType, OutputImageType> FilterType;
- typename FilterType::Pointer m = FilterType::New();
- m->SetMarkerImage(input);
- m->SetMaskImage(mask);
-
- filter=m;
- if(m_Verbose) std::cout<<"Using the reconstruction by erosion filter..."<<std::endl;
- break;
- }
-
- case 1:
- {
- typedef itk::ReconstructionByDilationImageFilter<InputImageType, OutputImageType> FilterType;
- typename FilterType::Pointer m = FilterType::New();
- m->SetMarkerImage(input);
- m->SetMaskImage(mask);
-
- filter=m;
- if(m_Verbose) std::cout<<"Using the reconstruction by dilation filter..."<<std::endl;
- break;
- break;
- }
-
- case 2:
- {
- typedef itk::ClosingByReconstructionImageFilter<InputImageType, OutputImageType, KernelType> FilterType;
- typename FilterType::Pointer m = FilterType::New();
- m->SetInput(input);
- m->SetKernel(structuringElement);
- m->SetFullyConnected(m_ArgsInfo.full_flag);
- m->SetPreserveIntensities(m_ArgsInfo.int_flag);
-
- filter=m;
- if(m_Verbose) std::cout<<"Using the closing by reconstruction filter..."<<std::endl;
- break;
-
- }
-
- case 3:
- {
- typedef itk::OpeningByReconstructionImageFilter<InputImageType, OutputImageType, KernelType> FilterType;
- typename FilterType::Pointer m = FilterType::New();
- m->SetInput(input);
- m->SetKernel(structuringElement);
- m->SetFullyConnected(m_ArgsInfo.full_flag);
- m->SetPreserveIntensities(m_ArgsInfo.int_flag);
-
- filter=m;
- if(m_Verbose) std::cout<<"Using the opening by reconstruction filter..."<<std::endl;
- break;
- }
- }
-
-
- //---------------------------------
- // Execute the filter
- //---------------------------------
- filter->SetInput(input);
- try
- {
- filter->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught executing the filter!" << std::endl;
- std::cerr << err << std::endl;
- return;
- }
- typename OutputImageType::Pointer output=filter->GetOutput();
-
-
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkMorphoReconstructionGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkAverageTemporalDimension.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkAverageTemporalDimension_ggo.h"
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkAverageTemporalDimensionGenericFilter.h"
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[])
-{
-
- // Init command line
- GGO(clitkAverageTemporalDimension, args_info);
- CLITK_INIT;
-
- // Filter
- typedef clitk::AverageTemporalDimensionGenericFilter<args_info_clitkAverageTemporalDimension> FilterType;
- FilterType::Pointer genericFilter = FilterType::New();
-
- genericFilter->SetArgsInfo(args_info);
- CLITK_TRY_CATCH_EXIT(genericFilter->Update());
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkAverageTemporalDimension.ggo
-package "clitkAverageTemporalDimension"
-version "1.0"
-purpose "Average the last dimension to an (n-1)D image. Input is either nD or multiple (n-1)D image or DVF"
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes multiple
-option "output" o "Output image filename" string yes
-
-
+++ /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://www.centreleonberard.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 clitkAverageTemporalDimensionGenericFilter_cxx
-#define clitkAverageTemporalDimensionGenericFilter_cxx
-
-/* =================================================
- * @file clitkAverageTemporalDimensionGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkAverageTemporalDimensionGenericFilter.h"
-
-
-namespace clitk
-{
-
-
-
-
-} //end clitk
-
-#endif //#define clitkAverageTemporalDimensionGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkAverageTemporalDimensionGenericFilter_h
-#define clitkAverageTemporalDimensionGenericFilter_h
-
-/* =================================================
- * @file clitkAverageTemporalDimensionGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkImageCommon.h"
-#include "clitkAverageTemporalDimension_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
- template<class args_info_type>
- class ITK_EXPORT AverageTemporalDimensionGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef AverageTemporalDimensionGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( AverageTemporalDimensionGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_type & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg[0];
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- AverageTemporalDimensionGenericFilter();
- ~AverageTemporalDimensionGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(const std::string PixelType, const int Components);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_type m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkAverageTemporalDimensionGenericFilter.txx"
-#endif
-
-#endif // #define clitkAverageTemporalDimensionGenericFilter_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://www.centreleonberard.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 clitkAverageTemporalDimensionGenericFilter_txx
-#define clitkAverageTemporalDimensionGenericFilter_txx
-
-/* =================================================
- * @file clitkAverageTemporalDimensionGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
-//-----------------------------------------------------------
-// Constructor
-//-----------------------------------------------------------
-template<class args_info_type>
-AverageTemporalDimensionGenericFilter<args_info_type>::AverageTemporalDimensionGenericFilter()
-{
- m_Verbose=false;
- m_InputFileName="";
-}
-
-
-//-----------------------------------------------------------
-// Update
-//-----------------------------------------------------------
-template<class args_info_type>
-void AverageTemporalDimensionGenericFilter<args_info_type>::Update()
-{
- // Read the Dimension and PixelType
- int Dimension, Components;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
-
-
- // Call UpdateWithDim
- if (m_ArgsInfo.input_given>1) Dimension+=1;
- if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
- else if(Dimension==3)UpdateWithDim<3>(PixelType, Components);
- else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
- else {
- std::cout<<"Error, Only for 2, 3 or 4D!!!"<<std::endl ;
- return;
- }
-}
-
-//-------------------------------------------------------------------
-// Update with the number of dimensions
-//-------------------------------------------------------------------
-template<class args_info_type>
-template<unsigned int Dimension>
-void
-AverageTemporalDimensionGenericFilter<args_info_type>::UpdateWithDim(const std::string PixelType, const int Components)
-{
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D with "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
-
- if (Components==1) {
- if(PixelType == "short") {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char") {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
- // else if (Components==2)
- // {
- // if (m_Verbose) std::cout << "Launching transform in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
- // UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 2> >();
- // }
-
- else if (Components==3) {
- if (m_Verbose) std::cout << "Launching transform in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
- UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
- }
-
- // else if (Components==4)
- // {
- // if (m_Verbose) std::cout << "Launching transform in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
- // UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
- // }
- else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
-}
-
-
-//-------------------------------------------------------------------
-// Update with the number of dimensions and the pixeltype
-//-------------------------------------------------------------------
-template<class args_info_type>
-template <unsigned int Dimension, class PixelType>
-void
-AverageTemporalDimensionGenericFilter<args_info_type>::UpdateWithDimAndPixelType()
-{
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension-1> OutputImageType;
- typename InputImageType::Pointer input;
-
- if (m_ArgsInfo.input_given ==1 ) {
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- input= reader->GetOutput();
- }
-
- else {
- // Read and join multiple inputs
- if (m_Verbose) std::cout<<m_ArgsInfo.input_given<<" inputs given..."<<std::endl;
- std::vector<std::string> filenames;
- for(unsigned int i=0; i<m_ArgsInfo.input_given; i++) {
- if (m_Verbose) std::cout<<m_ArgsInfo.input_arg[i]<<std::endl;
- filenames.push_back(m_ArgsInfo.input_arg[i]);
- }
-
- typedef itk::ImageSeriesReader<InputImageType> ImageReaderType;
- typename ImageReaderType::Pointer reader= ImageReaderType::New();
- reader->SetFileNames(filenames);
- reader->Update();
- input =reader->GetOutput();
- }
-
-
- // Output properties
- typename OutputImageType::RegionType region;
- typename OutputImageType::RegionType::SizeType size;
- typename OutputImageType::IndexType index;
- typename OutputImageType::SpacingType spacing;
- typename OutputImageType::PointType origin;
- typename InputImageType::RegionType region4D=input->GetLargestPossibleRegion();
- typename InputImageType::RegionType::SizeType size4D=region4D.GetSize();
- typename InputImageType::IndexType index4D=region4D.GetIndex();
- typename InputImageType::SpacingType spacing4D=input->GetSpacing();
- typename InputImageType::PointType origin4D=input->GetOrigin();
-
- for (unsigned int i=0; i< Dimension-1; i++) {
- size[i]=size4D[i];
- index[i]=index4D[i];
- spacing[i]=spacing4D[i];
- origin[i]=origin4D[i];
- }
- region.SetSize(size);
- region.SetIndex(index);
- typename OutputImageType::Pointer output= OutputImageType::New();
- output->SetRegions(region);
- output->SetSpacing(spacing);
- output->SetOrigin(origin);
- output->Allocate();
-
-
- // Region iterators
- typedef itk::ImageRegionIterator<InputImageType> IteratorType;
- std::vector<IteratorType> iterators(size4D[Dimension-1]);
- for (unsigned int i=0; i< size4D[Dimension-1]; i++) {
- typename InputImageType::RegionType regionIt=region4D;
- typename InputImageType::RegionType::SizeType sizeIt=regionIt.GetSize();
- sizeIt[Dimension-1]=1;
- regionIt.SetSize(sizeIt);
- typename InputImageType::IndexType indexIt=regionIt.GetIndex();
- indexIt[Dimension-1]=i;
- regionIt.SetIndex(indexIt);
- iterators[i]=IteratorType(input, regionIt);
- }
-
- typedef itk::ImageRegionIterator<OutputImageType> OutputIteratorType;
- OutputIteratorType avIt(output, output->GetLargestPossibleRegion());
-
- // Average
- PixelType vector;
- PixelType zeroVector=itk::NumericTraits<PixelType>::Zero;
- //zeroVector.Fill(0.0);
- while (!(iterators[0]).IsAtEnd()) {
- vector=zeroVector;
- for (unsigned int i=0; i<size4D[Dimension-1]; i++) {
- vector+=iterators[i].Get();
- ++(iterators[i]);
- }
- vector/=size4D[Dimension-1];
- avIt.Set(vector);
- ++avIt;
- }
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
-}
-
-
-}//end clitk
-
-#endif //#define clitkAverageTemporalDimensionGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkBSplineCoefficientsToValues.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkBSplineCoefficientsToValues_ggo.h"
-#include "clitkIO.h"
-#include "clitkBSplineCoefficientsToValuesGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkBSplineCoefficientsToValues, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::BSplineCoefficientsToValuesGenericFilter::Pointer genericFilter=clitk::BSplineCoefficientsToValuesGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkBSplineCoefficientsToValues.ggo
-package "clitkBSplineCoefficientsToValues"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-section "I/O"
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "matrix" m "Matrix transform to add" string no
-
-section "Options"
-option "like" l "Resample output this image (size, spacing,origin)" string no
-option "size" - "New output size if different from input" int no multiple
-option "spacing" - "New output spacing if different from input" double no multiple
-option "origin" - "New output origin if different from input" double no multiple
-option "pad" - "Edge padding value" double no default="0.0"
-option "order" - "Spline order of the coefficient image" int no default="3"
-
+++ /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://www.centreleonberard.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 clitkBSplineCoefficientsToValuesGenericFilter_cxx
-#define clitkBSplineCoefficientsToValuesGenericFilter_cxx
-
-/* =================================================
- * @file clitkBSplineCoefficientsToValuesGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkBSplineCoefficientsToValuesGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- BSplineCoefficientsToValuesGenericFilter::BSplineCoefficientsToValuesGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void BSplineCoefficientsToValuesGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension, Components;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
-
-
- // Call UpdateWithDim
- // if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
- if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
- //else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
- else
- {
- std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkBSplineCoefficientsToValuesGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkBSplineCoefficientsToValuesGenericFilter_h
-#define clitkBSplineCoefficientsToValuesGenericFilter_h
-
-/* =================================================
- * @file clitkBSplineCoefficientsToValuesGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkBSplineCoefficientsToValues_ggo.h"
-#include "clitkTransformUtilities.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkResampleImageFilter.h"
-#include "itkVectorResampleImageFilter.h"
-#include "itkBSplineResampleImageFunction.h"
-#include "clitkVectorBSplineResampleImageFunction.h"
-#include "itkAddImageFilter.h"
-#if ITK_VERSION_MAJOR >= 4
- #include "itkTransformToDisplacementFieldSource.h"
-#else
- #include "itkTransformToDeformationFieldSource.h"
-#endif
-
-namespace clitk
-{
-
-
- class ITK_EXPORT BSplineCoefficientsToValuesGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef BSplineCoefficientsToValuesGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( BSplineCoefficientsToValuesGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkBSplineCoefficientsToValues & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- BSplineCoefficientsToValuesGenericFilter();
- ~BSplineCoefficientsToValuesGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndVectorType();
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkBSplineCoefficientsToValues m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkBSplineCoefficientsToValuesGenericFilter.txx"
-#endif
-
-#endif // #define clitkBSplineCoefficientsToValuesGenericFilter_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://www.centreleonberard.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 clitkBSplineCoefficientsToValuesGenericFilter_txx
-#define clitkBSplineCoefficientsToValuesGenericFilter_txx
-#include <itkAffineTransform.h>
-
-/* =================================================
- * @file clitkBSplineCoefficientsToValuesGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- BSplineCoefficientsToValuesGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
-
- if (Components==1)
- {
- // if(PixelType == "short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed short>();
- // }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- // else if (PixelType == "unsigned_char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned char>();
- // }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- // else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- // }
- }
-
- else
- if (Components==3)
- {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
- UpdateWithDimAndVectorType<Dimension, itk::Vector<float, 3> >();
- }
-
- else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
-
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- BSplineCoefficientsToValuesGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- //Filter
- typedef itk::ResampleImageFilter< InputImageType,OutputImageType > ResampleFilterType;
- typename ResampleFilterType::Pointer resampler = ResampleFilterType::New();
-
- // Properties
- if (m_ArgsInfo.like_given)
- {
- typename InputReaderType::Pointer likeReader=InputReaderType::New();
- likeReader->SetFileName(m_ArgsInfo.like_arg);
- likeReader->Update();
- resampler->SetOutputParametersFromImage(likeReader->GetOutput());
- if (m_Verbose)std::cout<<"Resampling output like "<<m_ArgsInfo.like_arg<<"..."<<std::endl;
- }
- else
- {
- // Size
- typename OutputImageType::SizeType outputSize;
- if (m_ArgsInfo.size_given)
- {
- for(unsigned int i=0; i< Dimension; i++)
- outputSize[i]=m_ArgsInfo.size_arg[i];
- }
- else outputSize=input->GetLargestPossibleRegion().GetSize();
- if (m_Verbose)std::cout<<"Setting the size to "<<outputSize<<"..."<<std::endl;
-
- // Spacing
- typename OutputImageType::SpacingType outputSpacing;
- if (m_ArgsInfo.spacing_given)
- {
- for(unsigned int i=0; i< Dimension; i++)
- outputSpacing[i]=m_ArgsInfo.spacing_arg[i];
- }
- else outputSpacing=input->GetSpacing();
- if (m_Verbose)std::cout<<"Setting the spacing to "<<outputSpacing<<"..."<<std::endl;
-
- // Origin
- typename OutputImageType::PointType outputOrigin;
- if (m_ArgsInfo.origin_given)
- {
- for(unsigned int i=0; i< Dimension; i++)
- outputOrigin[i]=m_ArgsInfo.origin_arg[i];
- }
- else outputOrigin=input->GetOrigin();
- if (m_Verbose)std::cout<<"Setting the origin to "<<outputOrigin<<"..."<<std::endl;
-
- // Set
- resampler->SetSize( outputSize );
- resampler->SetOutputSpacing( outputSpacing );
- resampler->SetOutputOrigin( outputOrigin );
-
- }
-
- // Interp : coeff
- typedef itk::BSplineResampleImageFunction<InputImageType, double> InterpolatorType;
- typename InterpolatorType::Pointer interpolator=InterpolatorType::New();
- interpolator->SetSplineOrder(m_ArgsInfo.order_arg);
-
- // Set
- resampler->SetInterpolator( interpolator);
- resampler->SetDefaultPixelValue( static_cast<PixelType>(m_ArgsInfo.pad_arg) );
- resampler->SetInput( input );
-
- // Update
- try
- {
- resampler->Update();
- }
- catch(itk::ExceptionObject)
- {
- std::cerr<<"Error resampling the image"<<std::endl;
- }
-
- typename OutputImageType::Pointer output = resampler->GetOutput();
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the Vectortype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- BSplineCoefficientsToValuesGenericFilter::UpdateWithDimAndVectorType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- //Filter
- typedef itk::VectorResampleImageFilter< InputImageType,OutputImageType > ResampleFilterType;
- typename ResampleFilterType::Pointer resampler = ResampleFilterType::New();
-
- // Properties
- if (m_ArgsInfo.like_given)
- {
- typename InputReaderType::Pointer likeReader=InputReaderType::New();
- likeReader->SetFileName(m_ArgsInfo.like_arg);
- likeReader->Update();
-
- // Set
- resampler->SetSize( likeReader->GetOutput()->GetLargestPossibleRegion().GetSize() );
- resampler->SetOutputSpacing(likeReader->GetOutput()->GetSpacing() );
- resampler->SetOutputOrigin( likeReader->GetOutput()->GetOrigin() );
- if (m_Verbose)std::cout<<"Resampling output like "<<m_ArgsInfo.like_arg<<"..."<<std::endl;
- }
- else
- {
- // Size
- typename OutputImageType::SizeType outputSize;
- if (m_ArgsInfo.size_given)
- {
- for(unsigned int i=0; i< Dimension; i++)
- outputSize[i]=m_ArgsInfo.size_arg[i];
- }
- else outputSize=input->GetLargestPossibleRegion().GetSize();
- if (m_Verbose)std::cout<<"Setting the size to "<<outputSize<<"..."<<std::endl;
-
- // Spacing
- typename OutputImageType::SpacingType outputSpacing;
- if (m_ArgsInfo.spacing_given)
- {
- for(unsigned int i=0; i< Dimension; i++)
- outputSpacing[i]=m_ArgsInfo.spacing_arg[i];
- }
- else outputSpacing=input->GetSpacing();
- if (m_Verbose)std::cout<<"Setting the spacing to "<<outputSpacing<<"..."<<std::endl;
-
- // Origin
- typename OutputImageType::PointType outputOrigin;
- if (m_ArgsInfo.origin_given)
- {
- for(unsigned int i=0; i< Dimension; i++)
- outputOrigin[i]=m_ArgsInfo.origin_arg[i];
- }
- else outputOrigin=input->GetOrigin();
- if (m_Verbose)std::cout<<"Setting the origin to "<<outputOrigin<<"..."<<std::endl;
-
- // Set
- resampler->SetSize( outputSize );
- resampler->SetOutputSpacing( outputSpacing );
- resampler->SetOutputOrigin( outputOrigin );
-
- }
-
- // Interp : coeff
- typedef clitk::VectorBSplineResampleImageFunction<InputImageType, double> InterpolatorType;
- typename InterpolatorType::Pointer interpolator=InterpolatorType::New();
- interpolator->SetSplineOrder(m_ArgsInfo.order_arg);
-
-
- // Set
- resampler->SetInterpolator( interpolator);
- resampler->SetDefaultPixelValue( static_cast<PixelType>(m_ArgsInfo.pad_arg) );
- resampler->SetInput( input );
-
- // Update
- try
- {
- resampler->Update();
- }
- catch(itk::ExceptionObject)
- {
- std::cerr<<"Error resampling the image"<<std::endl;
- }
-
- typename OutputImageType::Pointer output = resampler->GetOutput();
- //writeImage<OutputImageType>(output, "/home/jef/tmp/output1.mhd", true);
-
-
- // Matrix Transform
- if(m_ArgsInfo.matrix_given)
- {
-#if ITK_VERSION_MAJOR >= 4
- typedef itk::TransformToDisplacementFieldSource<OutputImageType, double> ConvertorType;
-#else
- typedef itk::TransformToDeformationFieldSource<OutputImageType, double> ConvertorType;
-#endif
- typename ConvertorType::Pointer filter= ConvertorType::New();
- filter->SetOutputParametersFromImage(output);
-
- typedef itk::AffineTransform<double, Dimension> TransformType;
- typename TransformType::Pointer transform =TransformType::New();
- itk::Matrix<double, Dimension+1, Dimension+1> homMatrix= ReadMatrix<Dimension>( m_ArgsInfo.matrix_arg);
- itk::Matrix<double, Dimension, Dimension> matrix =GetRotationalPartMatrix( homMatrix);
- itk::Vector<double, Dimension> offset= GetTranslationPartMatrix( homMatrix);
- transform->SetMatrix(matrix);
- transform->SetOffset(offset);
- filter->SetTransform(transform);
- filter->Update();
- typename OutputImageType::Pointer output2=filter->GetOutput();
- //writeImage<OutputImageType>(output2, "/home/jef/tmp/output2.mhd", true);
-
- // Add
- typedef itk::AddImageFilter< OutputImageType, OutputImageType, OutputImageType > AddType;
- typename AddType::Pointer adder= AddType::New();
- adder->SetInput(output);
- adder->SetInput(1,output2);
- adder->Update();
- output=adder->GetOutput();
- }
-
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
- }
-
-}//end clitk
-
-#endif //#define clitkBSplineCoefficientsToValuesGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkChangeImageOrientation.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkChangeImageOrientation_ggo.h"
-#include "clitkIO.h"
-#include "clitkChangeImageOrientationGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkChangeImageOrientation, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::ChangeImageOrientationGenericFilter::Pointer genericFilter=clitk::ChangeImageOrientationGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkChangeImageOrientation.ggo
-package "clitkChangeImageOrientation"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-
-
+++ /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://www.centreleonberard.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 clitkChangeImageOrientationGenericFilter_cxx
-#define clitkChangeImageOrientationGenericFilter_cxx
-
-/* =================================================
- * @file clitkChangeImageOrientationGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkChangeImageOrientationGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- ChangeImageOrientationGenericFilter::ChangeImageOrientationGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void ChangeImageOrientationGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- // if(Dimension==2) UpdateWithDim<2>(PixelType);
- if(Dimension==3) UpdateWithDim<3>(PixelType);
- // else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 3 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkChangeImageOrientationGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkChangeImageOrientationGenericFilter_h
-#define clitkChangeImageOrientationGenericFilter_h
-
-/* =================================================
- * @file clitkChangeImageOrientationGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkChangeImageOrientation_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkOrientImageFilter.h"
-#include "itkSpatialOrientation.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT ChangeImageOrientationGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef ChangeImageOrientationGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( ChangeImageOrientationGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkChangeImageOrientation & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- ChangeImageOrientationGenericFilter();
- ~ChangeImageOrientationGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkChangeImageOrientation m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkChangeImageOrientationGenericFilter.txx"
-#endif
-
-#endif // #define clitkChangeImageOrientationGenericFilter_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://www.centreleonberard.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 clitkChangeImageOrientationGenericFilter_txx
-#define clitkChangeImageOrientationGenericFilter_txx
-
-/* =================================================
- * @file clitkChangeImageOrientationGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- ChangeImageOrientationGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- ChangeImageOrientationGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typedef itk::OrientImageFilter<InputImageType,InputImageType> OrientFilterType;
- typename OrientFilterType::Pointer orienter = itk::OrientImageFilter<InputImageType,InputImageType>::New();
- orienter->UseImageDirectionOn();
- orienter->SetDesiredCoordinateOrientation(itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RIP);
- orienter->SetInput(input);
- orienter->Update();
- typename OutputImageType::Pointer output=orienter->GetOutput();
-
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkChangeImageOrientationGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkCombineImage.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkCombineImage_ggo.h"
-#include "clitkIO.h"
-#include "clitkCombineImageGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkCombineImage, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::CombineImageGenericFilter::Pointer genericFilter=clitk::CombineImageGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- CLITK_TRY_CATCH_EXIT(genericFilter->Update());
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkCombineImage.ggo
-package "clitkCombineImage"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "input2" j "Input image filename" string yes
-option "mask" m "Binary image: if(mask) input1,else input2" string yes
-option "output" o "Output image filename" string yes
-
-
+++ /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://www.centreleonberard.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 clitkCombineImageFilter_h
-#define clitkCombineImageFilter_h
-
-/* =================================================
- * @file clitkCombineImageFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-
-//itk include
-#include "itkImageToImageFilter.h"
-
-namespace clitk
-{
-
- template <class InputImageType>
- class ITK_EXPORT CombineImageFilter :
- public itk::ImageToImageFilter<InputImageType, InputImageType>
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef CombineImageFilter Self;
- typedef itk::ImageToImageFilter<InputImageType, InputImageType> Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( CombineImageFilter, ImageToImageFilter );
-
- /** Dimension of the domain space. */
- itkStaticConstMacro(InputImageDimension, unsigned int, Superclass::InputImageDimension);
- itkStaticConstMacro(OutputImageDimension, unsigned int, Superclass::OutputImageDimension);
- typedef itk::Image<int, InputImageDimension> MaskImageType;
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
- typedef typename InputImageType::RegionType OutputImageRegionType;
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- itkBooleanMacro(Verbose);
- itkSetMacro( Verbose, bool);
- itkGetConstReferenceMacro( Verbose, bool);
-
- void SetMask(typename MaskImageType::Pointer m){m_Mask=m;}
- typename MaskImageType::Pointer GetMask(void){return m_Mask;}
-
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- CombineImageFilter();
- ~CombineImageFilter() {};
-
- //----------------------------------------
- // Update
- //----------------------------------------
- // Generate Data
- void ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId);
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- bool m_Verbose;
- typename MaskImageType::Pointer m_Mask;
-
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkCombineImageFilter.txx"
-#endif
-
-#endif // #define clitkCombineImageFilter_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://www.centreleonberard.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 clitkCombineImageFilter_txx
-#define clitkCombineImageFilter_txx
-
-/* =================================================
- * @file clitkCombineImageFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<class InputImageType>
- CombineImageFilter<InputImageType>::CombineImageFilter()
- {
- m_Verbose=false;
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template<class InputImageType>
- void
- CombineImageFilter<InputImageType>::ThreadedGenerateData(const OutputImageRegionType & outputRegionForThread, int threadId)
- {
- typename InputImageType::ConstPointer input1=this->GetInput(0);
- typename InputImageType::ConstPointer input2=this->GetInput(1);
- typename InputImageType::Pointer output=this->GetOutput();
-
- typedef itk::ImageRegionIterator<InputImageType> IteratorType;
- typedef itk::ImageRegionConstIterator<InputImageType> ConstIteratorType;
- typedef itk::ImageRegionConstIterator<MaskImageType> MaskIteratorType;
-
- ConstIteratorType it1(input1, outputRegionForThread);
- ConstIteratorType it2(input2, outputRegionForThread);
- MaskIteratorType itM(m_Mask, outputRegionForThread);
- IteratorType itO(output, outputRegionForThread);
-
- it1.GoToBegin();
- it2.GoToBegin();
- itM.GoToBegin();
- itO.GoToBegin();
-
- while(! itO.IsAtEnd())
- {
- if(itM.Get())
- itO.Set(it1.Get());
- else
- itO.Set(it2.Get());
-
- ++it1;
- ++it2;
- ++itM;
- ++itO;
- }
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkCombineImageFilter_txx
+++ /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://www.centreleonberard.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 clitkCombineImageGenericFilter_cxx
-#define clitkCombineImageGenericFilter_cxx
-
-/* =================================================
- * @file clitkCombineImageGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkCombineImageGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- CombineImageGenericFilter::CombineImageGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void CombineImageGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension, Components;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
- else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
- else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
- else
- {
- std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkCombineImageGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkCombineImageGenericFilter_h
-#define clitkCombineImageGenericFilter_h
-
-/* =================================================
- * @file clitkCombineImageGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkCombineImage_ggo.h"
-#include "clitkCombineImageFilter.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT CombineImageGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef CombineImageGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( CombineImageGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkCombineImage & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- CombineImageGenericFilter();
- ~CombineImageGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, int Components);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkCombineImage m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkCombineImageGenericFilter.txx"
-#endif
-
-#endif // #define clitkCombineImageGenericFilter_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://www.centreleonberard.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 clitkCombineImageGenericFilter_txx
-#define clitkCombineImageGenericFilter_txx
-
-/* =================================================
- * @file clitkCombineImageGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- CombineImageGenericFilter::UpdateWithDim(std::string PixelType, int Components)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
-
- if (Components==1)
- {
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
- else if (Components==3)
- {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
- UpdateWithDimAndPixelType<Dimension, itk::Vector<float, Dimension> >();
- }
- else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- CombineImageGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<int, Dimension> MaskImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the inputs
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input1= reader->GetOutput();
- typename InputReaderType::Pointer reader2 = InputReaderType::New();
- reader2->SetFileName( m_ArgsInfo.input2_arg);
- reader2->Update();
- typename InputImageType::Pointer input2= reader2->GetOutput();
-
- // Read the mask
- typedef itk::ImageFileReader<MaskImageType> MaskReaderType;
- typename MaskReaderType::Pointer mReader = MaskReaderType::New();
- mReader->SetFileName( m_ArgsInfo.mask_arg);
- mReader->Update();
- typename MaskImageType::Pointer mask= mReader->GetOutput();
-
- // Filter
- typedef CombineImageFilter<InputImageType> CombineImageFilterType;
- typename CombineImageFilterType::Pointer filter=CombineImageFilterType::New();
- filter->SetInput( input1 );
- filter->SetInput(1, input2 );
- filter->SetMask( mask );
- filter->Update();
- typename OutputImageType::Pointer output=filter->GetOutput();
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkCombineImageGenericFilter_txx
+++ /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://www.centreleonberard.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 CLITKCONEBEAMPROJECTIMAGE_CXX
-#define CLITKCONEBEAMPROJECTIMAGE_CXX
-/**
- =================================================
- * @file clitkConeBeamProjectImage.cxx
- * @author Jef Vandemeulebroucke <jefvdmb@gmail.com>
- * @date 30 April 2008
- *
- * @brief "Project a 3D image using a Cone-Beam geometry"
- =================================================*/
-
-// clitk include
-#include "clitkConeBeamProjectImage_ggo.h"
-#include "clitkConeBeamProjectImageGenericFilter.h"
-#include "clitkIO.h"
-#include "clitkImageCommon.h"
-#include "clitkTransformUtilities.h"
-
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkConeBeamProjectImage, args_info);
- CLITK_INIT;
-
- // Creation of a generic filter
- clitk::ConeBeamProjectImageGenericFilter::Pointer genericFilter = clitk::ConeBeamProjectImageGenericFilter::New();
-
- //Passing the arguments to the generic filter
- genericFilter->SetArgsInfo(args_info);
-
- // //Passing the arguments to the generic filter
- // genericFilter->SetVerbose(args_info.verbose_flag);
- // genericFilter->SetInput(args_info.input_arg);
- // genericFilter->SetOutput(args_info.output_arg);
- // //genericFilter->SetMask(args_info.mask_arg);
-
- // //set the three components of the isocenter
- // std::vector<double> iso(3);
- // for (unsigned int i=0 ; i<3 ; i++) iso[i]=args_info.iso_arg[i];
- // genericFilter->SetIsoCenter(iso);
- // genericFilter->SetSourceToScreen(args_info.screen_arg);
- // genericFilter->SetSourceToAxis(args_info.axis_arg);
- // genericFilter->SetProjectionAngle(args_info.angle_arg);
- // if (args_info.matrix_given) genericFilter->SetRigidTransformMatrix(clitk::ReadMatrix3D(args_info.matrix_arg));
- // genericFilter->SetEdgePaddingValue(args_info.pad_arg);
-
- //update
- genericFilter->Update();
-
- return 0;
-}
-
-#endif
-
-
+++ /dev/null
-#File clitkConeBeamProjectImage.ggo
-package "clitk"
-version "Project a 3D image with cone-beam geometry"
-
-option "config" - "Config file" string no
-
-section "Run Time"
-
-option "verbose" v "Verbose" flag off
-option "threads" - "Number of threads to use (default=min(cores,8))" int no
-
-
-section "Input"
-
-option "input" i "Input grid filename" string yes
-option "output" o "Output grid filename" string yes
-option "mask" m "2D Mask in which the filter should be applied (not supported yet;-)" string no
-
-
-section "Projection Parameters"
-
-option "iso" - "The isocenter" double no multiple default="0.0"
-option "screen" - "Specify the source to screen distance in mm" double no default="1536.0"
-option "axis" - "Specify the source to axis distance in mm" double no default="1000.0"
-option "angle" - "Specify the projection angle" double no default="0.0"
-option "matrix" - "Rigid tranform prior to projection (4x4)" string no
-option "pad" - "Padding value" float no default="0.0"
-
-
-section "Output Image"
-
-option "like" - "Make output like this image" string no
-option "origin" - "Origin for the output image" double multiple no default="0.0"
-option "size" - "Size for the output image" int multiple no default="512"
-option "spacing" - "Spacing for the output image" double multiple no default="0.8"
-
-option "panel_position" - "Approximate position of the panel: small, medium or large" string no default="small"
-option "panel_shift" - "Precise position of the panel in mm" double multiple no
+++ /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://www.centreleonberard.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 __clitkConeBeamProjectImageFilter_h
-#define __clitkConeBeamProjectImageFilter_h
-#include "clitkImageCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkTransformUtilities.h"
-#include "clitkExtractImageFilter.h"
-#include "itkRayCastInterpolateImageFunctionWithOrigin.h"
-
-//ITK include
-#include "itkLightObject.h"
-#include "itkResampleImageFilter.h"
-#include "itkEuler3DTransform.h"
-#include "itkExtractImageFilter.h"
-#include "itkFlipImageFilter.h"
-
-namespace clitk
-{
-
- template <class InputImageType, class OutputImageType >
- class ITK_EXPORT ConeBeamProjectImageFilter : public itk::LightObject
-
- {
- public:
-
- typedef ConeBeamProjectImageFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- /** Method for creation through the object factory. */
- itkNewMacro(Self);
-
- /** Determine the image dimension. */
- itkStaticConstMacro(InputImageDimension, unsigned int,
- InputImageType::ImageDimension );
-
- itkStaticConstMacro(OutputImageDimension, unsigned int,
- OutputImageType::ImageDimension );
-
-
- //========================================================================================
- //Typedefs
- typedef typename InputImageType::Pointer InputImagePointer;
- typedef typename InputImageType::ConstPointer InputImageConstPointer;
- typedef typename InputImageType::PixelType InputPixelType;
- typedef typename InputImageType::SizeType InputSizeType;
- typedef typename InputImageType::SpacingType InputSpacingType;
- typedef typename InputImageType::DirectionType InputDirectionType;
- typedef typename InputImageType::IndexType InputIndexType;
- typedef typename InputImageType::PointType InputPointType;
-
- typedef typename OutputImageType::Pointer OutputImagePointer;
- typedef typename OutputImageType::ConstPointer OutputImageConstPointer;
- typedef typename OutputImageType::PixelType OutputPixelType;
- typedef typename OutputImageType::SizeType OutputSizeType;
- typedef typename OutputImageType::SpacingType OutputSpacingType;
- typedef typename OutputImageType::DirectionType OutputDirectionType;
- typedef typename OutputImageType::IndexType OutputIndexType;
- typedef typename OutputImageType::PointType OutputPointType;
-
- typedef itk::Image<OutputPixelType, InputImageDimension> InternalImageType;
-
- //Pipeline
- typedef itk::Euler3DTransform <double> TransformType;
- typedef itk::ResampleImageFilter<InputImageType, InternalImageType > ResampleImageFilterType;
- typedef itk::RayCastInterpolateImageFunctionWithOrigin<InputImageType,double> InterpolatorType;
- typedef clitk::ExtractImageFilter<InternalImageType, OutputImageType> ExtractImageFilterType;
- typedef itk::FlipImageFilter<OutputImageType> FlipImageFilterType;
- typedef itk::Matrix<double,4,4> MatrixType;
-
- //========================================================================================
- //Set Methods
- //========================================================================================
- // Run-time
- void SetVerbose(const bool m){m_Verbose=m;}
- void SetNumberOfThreads(const unsigned int v)
- {
- m_NumberOfThreadsIsGiven=true;
- m_NumberOfThreads=v;
- }
-
- void SetInput(const InputImagePointer m) {m_Input=m;} //no reinitialize
-
- //=================================================================================
- //Geometry (reinitialize)
- void SetIsoCenter( const InputPointType & i )
- {
- if( m_IsoCenter!=i)
- {
- m_IsoCenter=i;
- m_IsInitialized=false;
- }
- }
-
- void SetSourceToScreen(const double& s)
- {
- if( m_SourceToScreen!=s)
- {
- m_SourceToScreen=s;
- m_IsInitialized=false;
- }
- }
-
- void SetSourceToAxis( const double& s)
- {
- if( m_SourceToAxis!=s)
- {
- m_SourceToAxis=s;
- m_IsInitialized=false;
- }
- }
-
- void SetProjectionAngle( const double& s)
- {
- if( m_SourceToScreen!=s)
- {
- m_ProjectionAngle=s;
- m_IsInitialized=false;
- }
- }
-
- void SetRigidTransformMatrix(const MatrixType& m)
- {
- if(m_RigidTransformMatrix != m)
- {
- m_RigidTransformMatrix=m;
- m_IsInitialized=false;
- }
- }
-
- void SetEdgePaddingValue(const OutputPixelType& p)
- {
- if (m_EdgePaddingValue!=p)
- {
- m_EdgePaddingValue=p;
- m_IsInitialized=false;
- }
- }
-
-
- //========================================================================================
- //Output image properties
- /** Get the size of the output image. */
- void SetOutputSize(const OutputSizeType& p)
- {
- if (m_OutputSize!=p)
- {
- m_OutputSize=p;
- m_IsInitialized=false;
- }
- }
-
- /** Set the output image spacing. */
- void SetOutputSpacing(const OutputSpacingType& p)
- {
- if (m_OutputSpacing!=p)
- {
- m_OutputSpacing=p;
- m_IsInitialized=false;
- }
- }
-
- /** Set the output image origin. */
- void SetOutputOrigin(const OutputPointType& p)
- {
- if (m_OutputOrigin!=p)
- {
- m_OutputOrigin=p;
- m_IsInitialized=false;
- }
- }
-
- /** Set the panelshift. */
- void SetPanelShift(double x, double y)
- {
- if (m_PanelShift[0] != x)
- {
- m_PanelShift[0] = x;
- m_IsInitialized=false;
- }
- if (m_PanelShift[1] != y)
- {
- m_PanelShift[1] = y;
- m_IsInitialized=false;
- }
- }
-
- /** Helper method to set the output parameters based on this image */
- void SetOutputParametersFromImage( const OutputImagePointer image );
-
- /** Helper method to set the output parameters based on this image */
- void SetOutputParametersFromImage( const OutputImageConstPointer image );
-
- //========================================================================================
- //Update
- void Initialize(void)throw (itk::ExceptionObject);
- void Update(void);
- OutputImagePointer GetOutput(void);
-
- protected:
- ConeBeamProjectImageFilter();
- ~ConeBeamProjectImageFilter() {};
-
- // Run time
- bool m_Verbose;
- bool m_NumberOfThreadsIsGiven;
- unsigned int m_NumberOfThreads;
- bool m_IsInitialized;
- //std::string m_Mask;
-
- // Data
- InputImageConstPointer m_Input;
- OutputImagePointer m_Output;
-
- // Geometry
- InputPointType m_IsoCenter;
- double m_SourceToScreen;
- double m_SourceToAxis;
- double m_ProjectionAngle;
- double m_PanelShift[2];
- MatrixType m_RigidTransformMatrix;
- OutputPixelType m_EdgePaddingValue;
-
- // Pipe
- TransformType::Pointer m_Transform;
- typename ResampleImageFilterType::Pointer m_Resampler;
- typename InterpolatorType::Pointer m_Interpolator;
- typename ExtractImageFilterType::Pointer m_ExtractImageFilter;
- typename FlipImageFilterType::Pointer m_FlipImageFilter;
-
- // Output image info
- OutputSizeType m_OutputSize; // Size of the output image
- OutputSpacingType m_OutputSpacing; // output image spacing
- OutputPointType m_OutputOrigin; // output image origin
- };
-
-
-} // end namespace clitk
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkConeBeamProjectImageFilter.txx"
-#endif
-
-#endif // #define __clitkConeBeamProjectImageFilter_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://www.centreleonberard.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 __clitkConeBeamProjectImageFilter_txx
-#define __clitkConeBeamProjectImageFilter_txx
-namespace clitk
-{
-
-
- //=========================================================================================================================
- //Constructor
- template <class InputImageType, class OutputImageType>
- ConeBeamProjectImageFilter<InputImageType, OutputImageType>::
- ConeBeamProjectImageFilter()
- {
- // Initialize with the default values (Elekta Synergie)
- m_Verbose=false;
- m_IsInitialized=false;
- m_NumberOfThreadsIsGiven=false;
-
- // Geometry
- m_IsoCenter.Fill(0.0);
- m_SourceToScreen=1536.;
- m_SourceToAxis=1000.;
- m_PanelShift[0] = 0.;
- m_PanelShift[1] = 0.;
- m_ProjectionAngle=0.;
- m_RigidTransformMatrix.SetIdentity();
- m_EdgePaddingValue=itk::NumericTraits<OutputPixelType>::Zero;//density images
-
- // Pipe
- m_Transform=TransformType::New();
- m_Resampler=ResampleImageFilterType::New();
- m_Interpolator= InterpolatorType::New();
- m_ExtractImageFilter=ExtractImageFilterType::New();
- m_FlipImageFilter=FlipImageFilterType::New();
-
- // Parameters for output
- this->m_OutputSpacing.Fill(0.8);
- this->m_OutputOrigin.Fill(0.0);
- this->m_OutputSize.Fill( 512 );
-
- }
-
-
- //-----------------------------------------------------------------------
- // Set output info from image
- //-----------------------------------------------------------------------
- template <class InputImageType, class OutputImageType>
- void
- ConeBeamProjectImageFilter<InputImageType, OutputImageType>
- ::SetOutputParametersFromImage ( OutputImagePointer image )
- {
- this->SetOutputOrigin( image->GetOrigin() );
- this->SetOutputSpacing( image->GetSpacing() );
- this->SetOutputSize( image->GetLargestPossibleRegion().GetSize() );
- }
-
-
- //-----------------------------------------------------------------------
- // Set output info from image
- //-----------------------------------------------------------------------
- template <class InputImageType, class OutputImageType>
- void
- ConeBeamProjectImageFilter<InputImageType, OutputImageType>
- ::SetOutputParametersFromImage ( OutputImageConstPointer image )
- {
- this->SetOutputOrigin( image->GetOrigin() );
- this->SetOutputSpacing( image->GetSpacing() );
- this->SetOutputSize( image->GetLargestPossibleRegion().GetSize() );
- }
-
-
- //=========================================================================================================================
- // Initialize
- template <class InputImageType, class OutputImageType>
- void
- ConeBeamProjectImageFilter<InputImageType, OutputImageType>
- ::Initialize(void) throw (itk::ExceptionObject)
- {
-
- //====================================================================
- // Define the transform: composition of rigid transfo around origin and a centered rotation
- // The center of rotation should be placed at the isocenter!
-
- if (m_Verbose) std::cout<<"The isocenter is at "<< m_IsoCenter <<"..." <<std::endl;
-
- // Get the rotation parameter array
- itk::Array<double> rotationParameters(3);
- const double dtr = ( atan(1.0) * 4.0 ) / 180.0; //constant for converting degrees into radians
- if (m_Verbose)std::cout<<"The projection angle is "<< m_ProjectionAngle <<"° (0° being lateral left)..."<< std::endl;
- rotationParameters[0]= 0.;
- rotationParameters[1]= 0.;
- rotationParameters[2]= -dtr*(double) m_ProjectionAngle;
-
- // We first perform rigid transform (of source and panel), then a centered rotation around the transformed center
- itk::Matrix<double,3,3> rigidRotation = GetRotationalPartMatrix3D(m_RigidTransformMatrix);
- itk::Vector<double,3> rigidTranslation = GetTranslationPartMatrix3D(m_RigidTransformMatrix);
- typename InputImageType::PointType transformedCenter = rigidRotation * m_IsoCenter + rigidTranslation;
-
- // Calculate the centered rotation matrix
- itk::Matrix<double,4,4> centeredRotationMatrix = GetCenteredRotationMatrix3D(rotationParameters,transformedCenter);
-
- // Compose this rotation with the rigid transform matrix
- itk::Matrix<double,4,4> finalTransform = m_RigidTransformMatrix * centeredRotationMatrix ;
-
- // Set the rotation
- itk::Matrix<double,3,3> finalRotation = GetRotationalPartMatrix3D(finalTransform);
- m_Transform->SetMatrix(finalRotation);
- if (m_Verbose)std::cout<<"The final rotation is "<<finalRotation<<"..."<<std::endl;
-
- // Set the translation
- itk::Vector<double,3> finalTranslation = GetTranslationPartMatrix3D(finalTransform);
- m_Transform->SetTranslation(finalTranslation);
- if (m_Verbose)std::cout<<"The final translation is "<<finalTranslation<<"..."<<std::endl;
-
-
- //====================================================================
- //Define a resample filter for the projection
- if (m_NumberOfThreadsIsGiven) m_Resampler->SetNumberOfThreads(m_NumberOfThreads);
- m_Resampler->SetDefaultPixelValue(m_EdgePaddingValue);
- if (m_Verbose)std::cout<<"The edge padding value is "<<m_EdgePaddingValue<<"..."<<std::endl;
-
- //JV Original raycast does not take into account origin, but does implicit shift to center of volume
- //JV patched in RayCastInterpolateImageFunctionWithOrigin
- m_Interpolator->SetTransform(m_Transform);
- m_Interpolator->SetThreshold(0.);
-
- // Focalpoint: we presume that for an angle of 0° the kV is lateral left (for the patient on his back), or on the positive X-axis.
- typename InterpolatorType::InputPointType focalpoint;
- focalpoint[0]= m_IsoCenter[0] + m_SourceToAxis;
- focalpoint[1]= m_IsoCenter[1];
- focalpoint[2]= m_IsoCenter[2];
- m_Interpolator->SetFocalPoint(focalpoint);
- if (m_Verbose)std::cout<<"The focalpoint is at "<< focalpoint <<"..."<< std::endl;
-
- // Connect the interpolator and the transform with the m_Resampler
- m_Resampler->SetInterpolator( m_Interpolator );
- m_Resampler->SetTransform( m_Transform );
-
- // Describe the output projection image
- typename InputImageType::SizeType sizeOuput;
- sizeOuput[0] = 1; // number of pixels along X of the 2D DRR image
- sizeOuput[1] = m_OutputSize[0]; // number of pixels along Y of the 2D DRR image
- sizeOuput[2] = m_OutputSize[1]; // number of pixels along Z of the 2D DRR image
- m_Resampler->SetSize( sizeOuput );
- if (m_Verbose)std::cout<<"The output size is "<< m_OutputSize <<"..."<< std::endl;
-
- typename InputImageType::SpacingType spacingOutput;
- spacingOutput[0] = 1; // pixel spacing along X of the 2D DRR image [mm]
- spacingOutput[1] = m_OutputSpacing[0]; // pixel spacing along Y of the 2D DRR image [mm]
- spacingOutput[2] = m_OutputSpacing[1]; // pixel spacing along Y of the 2D DRR image [mm]
- m_Resampler->SetOutputSpacing( spacingOutput );
- if (m_Verbose)std::cout<<"The output spacing is "<< m_OutputSpacing <<"..."<< std::endl;
-
- // The position of the DRR is specified, we presume that for an angle of 0° the flatpanel is located at the negative x-axis
- // JV -1 seems to correspond better with shearwarp of Simon Rit
- typename InterpolatorType::InputPointType originOutput;
- originOutput[0] = m_IsoCenter[0]- (m_SourceToScreen - m_SourceToAxis);
- DD(m_PanelShift);
- originOutput[1] = m_IsoCenter[1]-static_cast<double>(sizeOuput[1]-1)*spacingOutput[1]/2.0 - m_PanelShift[0];
- originOutput[2] = m_IsoCenter[2]-static_cast<double>(sizeOuput[2]-1)*spacingOutput[2]/2.0 - m_PanelShift[1];
- m_Resampler->SetOutputOrigin( originOutput );
- if (m_Verbose)std::cout<<"The origin of the flat panel is at "<< originOutput <<",..."<< std::endl;
-
- // We define the region to be extracted. Projection was in the YZ plane, X should be set to zero
- typename InternalImageType::RegionType::SizeType sizeTemp=sizeOuput;
- sizeTemp[0]=0;
- typename InternalImageType::IndexType startTemp; //=temp->GetLargestPossibleRegion().GetIndex();
- startTemp.Fill(0);
-
- typename InternalImageType::RegionType desiredRegion;
- desiredRegion.SetSize( sizeTemp );
- desiredRegion.SetIndex( startTemp );
- m_ExtractImageFilter->SetExtractionRegion( desiredRegion );
-
- // Prepare the Flip Image filter
- typename FlipImageFilterType::FlipAxesArrayType flipArray;
- flipArray[0] = 0;
- flipArray[1] = 1;
- m_FlipImageFilter->SetFlipAxes( flipArray );
-
- // Initialization complete
- m_IsInitialized=true;
-
- }
-
- //=========================================================================================================================
- // Update
- template <class InputImageType, class OutputImageType>
- void
- ConeBeamProjectImageFilter<InputImageType, OutputImageType>
- ::Update(void)
- {
-
- //==================================================================
- // If geometry changed reinitialize
- if (! m_IsInitialized) this->Initialize();
-
- // Input
- m_Resampler->SetInput( m_Input );
-
- //==================================================================
- // Execute the filter
- if (m_Verbose)std::cout<<"Starting the projection..."<<std::endl;
- try {
- m_Resampler->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught! Projection failed!" << std::endl;
- std::cerr << err << std::endl;
- }
-
- //==================================================================
- // Make a 2D image out of it
- typename InternalImageType::Pointer temp=m_Resampler->GetOutput();
- m_ExtractImageFilter->SetInput(temp);
-
- // We should flip the Y axis
- m_FlipImageFilter->SetInput(m_ExtractImageFilter->GetOutput());
- m_FlipImageFilter->Update();
-
- // Get output
- m_Output= m_FlipImageFilter->GetOutput();
- m_Output->Update();
- m_Output->SetOrigin(m_OutputOrigin);
- }
-
- //=========================================================================================================================
- // GetOutput
- template <class InputImageType, class OutputImageType>
- typename OutputImageType::Pointer
- ConeBeamProjectImageFilter<InputImageType, OutputImageType>
- ::GetOutput(void)
- {
- //JV it is not safe to repeatedly call getoutput/ always call Update first
- return m_Output;
- }
-
-}
-
-
-#endif
+++ /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://www.centreleonberard.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_CXX
-#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER_CXX
-
-/**
- * @file clitkConeBeamProjectImageGenericFilter.cxx
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date Wed April 30 13:47:57 2008
- *
- * @brief
- *
- *
- */
-
-#include "clitkConeBeamProjectImageGenericFilter.h"
-
-namespace clitk
-{
-
- //====================================================================
- // Constructor
- ConeBeamProjectImageGenericFilter::ConeBeamProjectImageGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
- //====================================================================
- // Update
- void ConeBeamProjectImageGenericFilter::Update()
- {
- //Read the PixelType and dimension of the input image
- int Dimension;
- std::string PixelType;
- clitk::ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
- if (Dimension == 3)
- {
- if (m_Verbose) std::cout << "Input was detected to be "<< Dimension << "D and " << PixelType << "..." << std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching Projection in signed short..." << std::endl;
- UpdateWithPixelType<signed short>();
- }
-
-// else if(PixelType == "unsigned_short"){
-// if (m_Verbose) std::cout << "Launching Projection in unsigned_short..." << std::endl;
-// UpdateWithPixelType<unsigned short>();
-// }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching Projection in unsigned_char..." << std::endl;
- UpdateWithPixelType<unsigned char>();
- }
-
-// else if (PixelType == "char"){
-// if (m_Verbose) std::cout << "Launching Projection in signed_char..." << std::endl;
-// UpdateWithPixelType<signed char>();
-// }
- else {
- if (m_Verbose) std::cout << "Launching Projection in float..." << std::endl;
- UpdateWithPixelType<float>();
- }
- }
-
- else {itkExceptionMacro(<< "Input Image dimension is " << Dimension
- << " 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));
-
- DD(m_ArgsInfo.panel_position_arg);
- if (m_ArgsInfo.panel_shift_given) // one should read the specific values for each angle in Frame.dbf
- filter->SetPanelShift(m_ArgsInfo.panel_shift_arg[0], m_ArgsInfo.panel_shift_arg[1]);
- else { // approximate panel positions hard coded values for the elekta synergy
- if (strcmp(m_ArgsInfo.panel_position_arg,"small") ==0)
- filter->SetPanelShift(0., 0.);
- else if (strcmp(m_ArgsInfo.panel_position_arg,"medium") ==0)
- filter->SetPanelShift(114.84, 0.); // VD : 120 , 0 ?
- else if (strcmp(m_ArgsInfo.panel_position_arg,"large") ==0)
- filter->SetPanelShift(190., 0.);
- else assert(false); //Unsupported panel position
- }
- // 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 CLITKCONEBEAMPROJECTIMAGEGENERICFILTER_CXX
+++ /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://www.centreleonberard.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__H
-#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER__H
-/**
- =================================================
- * @file clitkConeBeamProjectImageGenericFilter.h
- * @author Jef Vandemeulebroucke <jef@creatis.insa-lyon.fr>
- * @date 30 April 2008
- *
- * @brief Project a 3D image using a ConeBeam geometry
- *
- =================================================*/
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkImageCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkConeBeamProjectImageFilter.h"
-#include "clitkConeBeamProjectImage_ggo.h"
-
-// itk include
-#include "itkLightObject.h"
-
-
-namespace clitk {
-
- //====================================================================
- class ConeBeamProjectImageGenericFilter: public itk::LightObject
- {
- public:
-
- //Typedefs ITK================================================
- typedef ConeBeamProjectImageGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- //ITK Method for object creation================================================
- itkNewMacro(Self);
-
-
- //====================================================================
- // Set methods
- void SetArgsInfo(const args_info_clitkConeBeamProjectImage a)
- {
- m_ArgsInfo=a;
- m_InputFileName=m_ArgsInfo.input_arg;
- m_Verbose=m_ArgsInfo.verbose_flag;
- }
-
-
- //====================================================================
- // Update
- virtual void Update();
-
- protected:
- const char * GetNameOfClass() const { return "ConeBeamProjectImageGenericFilter"; }
-
- //====================================================================
- // Constructor & Destructor
- ConeBeamProjectImageGenericFilter();
- ~ConeBeamProjectImageGenericFilter(){;}
-
- //====================================================================
- //Protected member functions
- template <class PixelType> void UpdateWithPixelType();
-
- bool m_Verbose;
- std::string m_InputFileName;
- args_info_clitkConeBeamProjectImage m_ArgsInfo;
-
- };
-
-} // end namespace clitk
-
-#endif //#define CLITKCONEBEAMPROJECTIMAGEGENERICFILTER__H
+++ /dev/null
-/*=========================================================================
- Program: vv http://www.creatis.insa-lyon.fr/rio/vv
- Main authors : XX XX XX
-
- Authors belongs to:
- - University of LYON http://www.universite-lyon.fr/
- - Léon Bérard cancer center http://www.centreleonberard.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 http://www.opensource.org/licenses/bsd-license.php
- - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
-
- =========================================================================*/
-
-#include "clitkDicomRT_StructureSet.h"
-#include "clitkDicomRTStructInfo_ggo.h"
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkDicomRTStructInfo, args_info);
-
- // Read and display information
- clitk::DicomRT_StructureSet s;
- s.Read(args_info.input_arg);
- s.Print(std::cout);
-
- // This is the end my friend
- return 0;
-}
+++ /dev/null
-# file clitkDicomRTStructInfo.ggo
-package "clitk"
-version "Read and print DICOM RT Structure set file (contours)"
-
-option "config" - "Config file" string no
-option "input" i "Input Dicom file" string yes
-
-#option "roi" r "ROI to print (ID)" int no
-#option "contour" c "contour to print (ID)" int no
-#option "offset" o "to display points as image offsets" flag off
-
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkFilter_ggo.h"
-#include "clitkIO.h"
-#include "clitkFilterGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkFilter, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::FilterGenericFilter::Pointer genericFilter=clitk::FilterGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkFilter.ggo
-package "clitkFilter"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "mask" m "Mask in which the filter should be applied" string no
-
-option "float" - "Convert to float first " flag off
-
-section "Filter"
-
-option "type" t "Type of filter: 0=derivative, 1= gradient magnitude, 2= projection, 3= intensity windowing, 4=BSplineDownsampling with factor 2, 5=normalize intensities (mean=0 ,SD=1), 6=anisotropic diffusion, 7=gradient anisotropic diffusion, 8=curvature anisotropic diffusion, 9= curvature flow" int no default="0"
-option "order" - "0: what order" int no default="1"
-option "direction" - "0-2: what direction" int no default="0"
-option "projection" - "2: what accumulation (0=sum, 1=max, 2=min) " int no default="0"
-option "inputMin" - "3: set window minimum" float no default="0"
-option "inputMax" - "3: set window maximum" float no default="100"
-option "outputMin" - "3: set output minimum" float no default="0"
-option "outputMax" - "3: set output maximum" float no default="255"
-option "resamplerType" - "4: Resampler type to use for the downsampling (0=Standard, 1=Centered, 2=L2, 3=L2Centered) " int no default="0"
-option "splineOrder" - "4: SplineOrder to use for the downsampling (0-5, some resamplers only odd) " int no default="3"
-option "cond" - "6-8: conductance parameter" double no default="3.0"
-option "time" - "6-9: Time step (6,7: 0.25 for 2D and 0.125 for 3D; 8,9:0.125 for 2D and 0.0625 for 3D)" double no default="0.125"
-option "iter" - "6-9: Iterations (6-8=5; 9=10)" double no default="5"
-option "radius" - "9: radius" double no default="1"
+++ /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://www.centreleonberard.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 clitkFilterGenericFilter_cxx
-#define clitkFilterGenericFilter_cxx
-
-/* =================================================
- * @file clitkFilterGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkFilterGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- FilterGenericFilter::FilterGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void FilterGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2 or 3 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkFilterGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkFilterGenericFilter_h
-#define clitkFilterGenericFilter_h
-
-/* =================================================
- * @file clitkFilterGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkFilter_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkCastImageFilter.h"
-#include "itkDerivativeImageFilter.h"
-#include "itkGradientMagnitudeImageFilter.h"
-#include "itkSumProjectionImageFilter.h"
-#include "itkMaximumProjectionImageFilter.h"
-#include "itkMinimumProjectionImageFilter.h"
-#include "itkAccumulateImageFilter.h"
-#include "itkIntensityWindowingImageFilter.h"
-#include "itkRescaleIntensityImageFilter.h"
-#include "itkSmoothingRecursiveGaussianImageFilter.h"
-#include "itkDiscreteGaussianImageFilter.h"
-#include "itkBSplineDownsampleImageFilter.h"
-#include "itkNormalizeImageFilter.h"
-#include "itkAnisotropicDiffusionImageFilter.h"
-#include "itkGradientAnisotropicDiffusionImageFilter.h"
-#include "itkCurvatureAnisotropicDiffusionImageFilter.h"
-#include "itkCurvatureFlowImageFilter.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT FilterGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef FilterGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( FilterGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkFilter & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- FilterGenericFilter();
- ~FilterGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkFilter m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkFilterGenericFilter.txx"
-#endif
-
-#endif // #define clitkFilterGenericFilter_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://www.centreleonberard.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 clitkFilterGenericFilter_txx
-#define clitkFilterGenericFilter_txx
-
-/* =================================================
- * @file clitkFilterGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- FilterGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
-// if(PixelType == "short"){
-// if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
-// UpdateWithDimAndPixelType<Dimension, signed short>();
-// }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
-// else if (PixelType == "unsigned_char"){
-// if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
-// UpdateWithDimAndPixelType<Dimension, unsigned char>();
-// }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- // else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
-// }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class InternalPixelType>
- void
- FilterGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<InternalPixelType, Dimension> InputImageType;
- typedef itk::Image<InternalPixelType, Dimension> InternalImageType;
- typedef itk::Image<InternalPixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
-
- // Filter
- typedef itk::ImageToImageFilter< InternalImageType, InternalImageType > ImageToImageFilterType;
- typename ImageToImageFilterType::Pointer filter;
-
- switch ( m_ArgsInfo.type_arg ){
-
- case 0:{
- typename itk::DerivativeImageFilter< InternalImageType,InternalImageType >::Pointer df = itk::DerivativeImageFilter<InternalImageType,InternalImageType >::New();
-
- //Set parameters
- df->SetDirection(m_ArgsInfo.direction_arg);
- df->SetOrder(m_ArgsInfo.order_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the derivative image filter with order "<<m_ArgsInfo.order_arg <<" on direction "<< m_ArgsInfo.direction_arg << "..." << std::endl;
- break;
- }
- case 1:{
- typename itk::GradientMagnitudeImageFilter< InternalImageType,InternalImageType >::Pointer gf = itk::GradientMagnitudeImageFilter<InternalImageType,InternalImageType >::New();
-
- //Set parameters
- gf->SetUseImageSpacingOn();
-
- filter=gf;
- if (m_Verbose) std::cout<<"Using the gradient magnitude image filter... "<< std::endl;
- break;
- }
- case 2:{
-
- switch ( m_ArgsInfo.projection_arg ){
-
- case 0:{
- //Sum
- typename itk::SumProjectionImageFilter< InternalImageType,InternalImageType >::Pointer pf = itk::SumProjectionImageFilter<InternalImageType,InternalImageType>::New();
- //Set parameters
- pf->SetProjectionDimension(m_ArgsInfo.direction_arg);
-
- filter=pf;
- if (m_Verbose) std::cout<<"Using the Sum projection image filter on the dimension "<< m_ArgsInfo.direction_arg << "..."<<std::endl;
- break;
- }
- case 1:{
- //Max
- typename itk::MaximumProjectionImageFilter< InternalImageType,InternalImageType >::Pointer pf = itk::MaximumProjectionImageFilter<InternalImageType,InternalImageType>::New();
- //Set parameters
- pf->SetProjectionDimension(m_ArgsInfo.direction_arg);
-
- filter=pf;
- if (m_Verbose) std::cout<<"Using the maximum intensity projection image filter on the dimension "<< m_ArgsInfo.direction_arg << "..."<<std::endl;
- break;
- }
- case 2:{
- //Sum
- typename itk::MinimumProjectionImageFilter< InternalImageType,InternalImageType >::Pointer pf = itk::MinimumProjectionImageFilter<InternalImageType,InternalImageType>::New();
- //Set parameters
- pf->SetProjectionDimension(m_ArgsInfo.direction_arg);
-
- filter=pf;
- if (m_Verbose) std::cout<<"Using the minimum intensity projection image filter on the dimension "<< m_ArgsInfo.direction_arg << "..."<<std::endl;
- break;
- }
- }
- break;
- }//end case projection filter
-
- case 3: {
- typename itk::IntensityWindowingImageFilter< InternalImageType,InternalImageType >::Pointer pf
- = itk::IntensityWindowingImageFilter<InternalImageType,InternalImageType>::New();
- //Set parameters
- pf->SetWindowMinimum((InternalPixelType) m_ArgsInfo.inputMin_arg);
- pf->SetWindowMaximum((InternalPixelType) m_ArgsInfo.inputMax_arg);
- pf->SetOutputMinimum((InternalPixelType) m_ArgsInfo.outputMin_arg);
- pf->SetOutputMaximum((InternalPixelType) m_ArgsInfo.outputMax_arg);
-
- filter=pf;
- if (m_Verbose) std::cout<<"Using the window intensity image filter with the window min and max being "
- << m_ArgsInfo.inputMin_arg << " and "<< m_ArgsInfo.inputMax_arg
- <<" and the output min and max being "<<m_ArgsInfo.outputMin_arg<<" and "
- << m_ArgsInfo.outputMax_arg << std::endl;
- break;
- }
- case 4: {
-
- //Downsample using bsplines: four types of resamplers
- typedef itk::BSplineResampleImageFilterBase<InternalImageType, InternalImageType> ResamplerType;
- typedef itk::BSplineCenteredResampleImageFilterBase<InternalImageType, InternalImageType> CenteredResamplerType;
- typedef itk::BSplineL2ResampleImageFilterBase<InternalImageType, InternalImageType> L2ResamplerType;
- typedef itk::BSplineCenteredL2ResampleImageFilterBase<InternalImageType, InternalImageType> CenteredL2ResamplerType;
-
- //ResamplerType
- if(m_ArgsInfo.resamplerType_arg==0)
- {
- typename itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, ResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with Standard Resampler"<<std::endl;
- }
- //CenteredResamplerType
- else if(m_ArgsInfo.resamplerType_arg==1)
- {
- typename itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, CenteredResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, CenteredResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with Centered Resampler"<<std::endl;
- }
- //L2ResamplerType
- else if(m_ArgsInfo.resamplerType_arg==2)
- {
- typename itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, L2ResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType,L2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 Resampler"<<std::endl;
- }
- else if(m_ArgsInfo.resamplerType_arg==3)
- {
- typename itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType, CenteredL2ResamplerType >::Pointer df
- = itk::BSplineDownsampleImageFilter< InternalImageType,InternalImageType,CenteredL2ResamplerType >::New();
- df->SetSplineOrder(m_ArgsInfo.splineOrder_arg);
- filter=df;
- if (m_Verbose) std::cout<<"Using the BSpline downsample image filter with L2 Centered Resampler"<<std::endl;
- }
- break;
- }
- case 5: {
- typedef itk::NormalizeImageFilter<InternalImageType, InternalImageType> NormalizeFilterType;
- typename NormalizeFilterType::Pointer df = NormalizeFilterType::New();
- filter=df;
- if (m_Verbose) std::cout << "Normalizing image intensities to a zero mean and 1 SD (float!)..." << std::endl;
- break;
- }
-// case 6: {
-// typedef itk::AnisotropicDiffusionImageFilter<InternalImageType, InternalImageType> FilterType;
-// typename FilterType::Pointer df = FilterType::New();
-// df->SetConductanceParameter(m_ArgsInfo.cond_arg);
-// df->SetNumberOfIterations(m_ArgsInfo.iter_arg);
-// df->SetTimeStep(m_ArgsInfo.time_arg);
-// df->SetUseImageSpacing(true);
-
-// filter=df;
-// if (m_Verbose) std::cout << "Using the anisotropic diffusion image filter..." << std::endl;
-// break;
-// }
-
- case 7: {
- typedef itk::GradientAnisotropicDiffusionImageFilter<InternalImageType, InternalImageType> FilterType;
- typename FilterType::Pointer df = FilterType::New();
- df->SetConductanceParameter(m_ArgsInfo.cond_arg);
- df->SetNumberOfIterations(m_ArgsInfo.iter_arg);
- df->SetTimeStep(m_ArgsInfo.time_arg);
- df->SetUseImageSpacing(true);
-
- filter=df;
- if (m_Verbose) std::cout << "Using the gradient anisotropic diffusion image filter..." << std::endl;
- break;
- }
-
- case 8: {
- typedef itk::CurvatureAnisotropicDiffusionImageFilter<InternalImageType, InternalImageType> FilterType;
- typename FilterType::Pointer df = FilterType::New();
- df->SetConductanceParameter(m_ArgsInfo.cond_arg);
- df->SetNumberOfIterations(m_ArgsInfo.iter_arg);
- df->SetTimeStep(m_ArgsInfo.time_arg);
- df->SetUseImageSpacing(true);
-
- filter=df;
- if (m_Verbose) std::cout << "Using the Curvature anisotropic diffusion image filter..." << std::endl;
- break;
- }
-
- case 9: {
- typedef itk::CurvatureFlowImageFilter<InternalImageType, InternalImageType> FilterType;
- typename FilterType::Pointer df = FilterType::New();
- df->SetTimeStep(m_ArgsInfo.time_arg);
- df->SetUseImageSpacing(true);
- df->SetNumberOfIterations(m_ArgsInfo.iter_arg);
- filter=df;
- if (m_Verbose) std::cout << "Using the curvature flow image filter......" << std::endl;
- break;
- }
-
-
- }//end switch filterType
-
-
- //==================================================================
- //execute the filter
- filter->SetInput(input);
-
-
- if (m_Verbose)std::cout<<"Starting filter..."<<std::endl;
-
- try {
- filter->Update();
- }
- catch( itk::ExceptionObject & err )
- {
- std::cerr << "ExceptionObject caught! Filter failed!" << std::endl;
- std::cerr << err << std::endl;
- return;
- }
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(filter->GetOutput());
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkFilterGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkGetDirection.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkGetDirection_ggo.h"
-#include "clitkIO.h"
-#include "clitkGetDirectionGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkGetDirection, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::GetDirectionGenericFilter::Pointer genericFilter=clitk::GetDirectionGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkGetDirection.ggo
-package "clitkGetDirection"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-
-
+++ /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://www.centreleonberard.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 clitkGetDirectionGenericFilter_cxx
-#define clitkGetDirectionGenericFilter_cxx
-
-/* =================================================
- * @file clitkGetDirectionGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkGetDirectionGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- GetDirectionGenericFilter::GetDirectionGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void GetDirectionGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2,3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkGetDirectionGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkGetDirectionGenericFilter_h
-#define clitkGetDirectionGenericFilter_h
-
-/* =================================================
- * @file clitkGetDirectionGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkGetDirection_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT GetDirectionGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef GetDirectionGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( GetDirectionGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkGetDirection & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- GetDirectionGenericFilter();
- ~GetDirectionGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkGetDirection m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkGetDirectionGenericFilter.txx"
-#endif
-
-#endif // #define clitkGetDirectionGenericFilter_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://www.centreleonberard.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 clitkGetDirectionGenericFilter_txx
-#define clitkGetDirectionGenericFilter_txx
-
-/* =================================================
- * @file clitkGetDirectionGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- GetDirectionGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- GetDirectionGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typename InputImageType::DirectionType direction=input->GetDirection();
- for (unsigned int i=0;i<Dimension;i++)
- for (unsigned int j=0;j<Dimension;j++)
- {
- if (i+j !=0)std::cout<<",";
- std::cout<<direction[i][j];
- }
- std::cout<<std::endl;
-
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkGetDirectionGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkGetOrigin.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkGetOrigin_ggo.h"
-#include "clitkIO.h"
-#include "clitkGetOriginGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkGetOrigin, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::GetOriginGenericFilter::Pointer genericFilter=clitk::GetOriginGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkGetOrigin.ggo
-package "clitkGetOrigin"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "comma" o "Output comma separated values" flag off
-
-
+++ /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://www.centreleonberard.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 clitkGetOriginGenericFilter_cxx
-#define clitkGetOriginGenericFilter_cxx
-
-/* =================================================
- * @file clitkGetOriginGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkGetOriginGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- GetOriginGenericFilter::GetOriginGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void GetOriginGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2 or 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkGetOriginGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkGetOriginGenericFilter_h
-#define clitkGetOriginGenericFilter_h
-
-/* =================================================
- * @file clitkGetOriginGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkGetOrigin_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT GetOriginGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef GetOriginGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( GetOriginGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkGetOrigin & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- GetOriginGenericFilter();
- ~GetOriginGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkGetOrigin m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkGetOriginGenericFilter.txx"
-#endif
-
-#endif // #define clitkGetOriginGenericFilter_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://www.centreleonberard.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 clitkGetOriginGenericFilter_txx
-#define clitkGetOriginGenericFilter_txx
-
-/* =================================================
- * @file clitkGetOriginGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- GetOriginGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- GetOriginGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- //Get Origin
- typename InputImageType::PointType origin=input->GetOrigin();
- for(unsigned int i=0; i<Dimension-1; i++)
- {
- std::cout<<origin[i];
- if (!m_ArgsInfo.comma_flag)std::cout<<" ";
- else std::cout<<",";
- }
- std::cout<<origin[Dimension-1]<<std::endl;
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkGetOriginGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkGetSize.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkGetSize_ggo.h"
-#include "clitkIO.h"
-#include "clitkGetSizeGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkGetSize, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::GetSizeGenericFilter::Pointer genericFilter=clitk::GetSizeGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkGetSize.ggo
-package "clitkGetSize"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "comma" c "Output comma separated values" flag off
-
-
+++ /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://www.centreleonberard.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 clitkGetSizeGenericFilter_cxx
-#define clitkGetSizeGenericFilter_cxx
-
-/* =================================================
- * @file clitkGetSizeGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkGetSizeGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- GetSizeGenericFilter::GetSizeGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void GetSizeGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2 or 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkGetSizeGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkGetSizeGenericFilter_h
-#define clitkGetSizeGenericFilter_h
-
-/* =================================================
- * @file clitkGetSizeGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkGetSize_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT GetSizeGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef GetSizeGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( GetSizeGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkGetSize & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- GetSizeGenericFilter();
- ~GetSizeGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkGetSize m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkGetSizeGenericFilter.txx"
-#endif
-
-#endif // #define clitkGetSizeGenericFilter_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://www.centreleonberard.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 clitkGetSizeGenericFilter_txx
-#define clitkGetSizeGenericFilter_txx
-
-/* =================================================
- * @file clitkGetSizeGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- GetSizeGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- // if(PixelType == "short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed short>();
- // }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- //else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- //}
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- // else {
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, float>();
- // }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- GetSizeGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typename InputImageType::SizeType size=input->GetLargestPossibleRegion().GetSize();
- for(unsigned int i=0; i<Dimension-1; i++)
- {
- std::cout<<size[i];
- if (!m_ArgsInfo.comma_flag)std::cout<<" ";
- else std::cout<<",";
- }
- std::cout<<size[Dimension-1]<<std::endl;
-
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkGetSizeGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkGetSpacing.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkGetSpacing_ggo.h"
-#include "clitkIO.h"
-#include "clitkGetSpacingGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkGetSpacing, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::GetSpacingGenericFilter::Pointer genericFilter=clitk::GetSpacingGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkGetSpacing.ggo
-package "clitkGetSpacing"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "comma" o "Output comma separated values" flag off
-
-
+++ /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://www.centreleonberard.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 clitkGetSpacingGenericFilter_cxx
-#define clitkGetSpacingGenericFilter_cxx
-
-#include "clitkGetSpacingGenericFilter.h"
-
-namespace clitk
-{
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- GetSpacingGenericFilter::GetSpacingGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void GetSpacingGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2 or 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkGetSpacingGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkGetSpacingGenericFilter_h
-#define clitkGetSpacingGenericFilter_h
-
-/* =================================================
- * @file clitkGetSpacingGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkGetSpacing_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT GetSpacingGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef GetSpacingGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( GetSpacingGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkGetSpacing & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- GetSpacingGenericFilter();
- ~GetSpacingGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkGetSpacing m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkGetSpacingGenericFilter.txx"
-#endif
-
-#endif // #define clitkGetSpacingGenericFilter_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://www.centreleonberard.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 clitkGetSpacingGenericFilter_txx
-#define clitkGetSpacingGenericFilter_txx
-
-/* =================================================
- * @file clitkGetSpacingGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- GetSpacingGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- // if(PixelType == "short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed short>();
- // }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- // else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- // }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- // else {
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, float>();
- // }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- GetSpacingGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typename InputImageType::SpacingType spacing=input->GetSpacing();
- for(unsigned int i=0; i<Dimension-1; i++)
- {
- std::cout<<spacing[i];
- if (!m_ArgsInfo.comma_flag)std::cout<<" ";
- else std::cout<<",";
- }
- std::cout<<spacing[Dimension-1]<<std::endl;
- }
-
-
-}//end clitk
-
-#endif //#define clitkGetSpacingGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-/**
- ------------------------------------------------=
- * @file clitkGuerreroVentilation.cxx
- * @author Joël Schaerer
- * @date 20 April 2009
- ------------------------------------------------=*/
-
-// clitk include
-#include "clitkGuerreroVentilation_ggo.h"
-#include "clitkGuerreroVentilationGenericFilter.h"
-#include "clitkIO.h"
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[])
-{
-
- // Init command line
- GGO(clitkGuerreroVentilation, args_info);
- CLITK_INIT;
-
- // Read image dimension
- itk::ImageIOBase::Pointer header = clitk::readImageHeader(args_info.input_arg);
- //unsigned int dim = header->GetNumberOfDimensions();
-
- // Check parameters
- // Main filter
- clitk::GuerreroVentilationGenericFilter filter;
- filter.SetInputFilename(args_info.input_arg);
- filter.AddInputFilename(args_info.ref_arg);
- filter.SetOutputFilename(args_info.output_arg);
- filter.SetBloodCorrectionFactor(args_info.factor_arg);
- filter.SetUseCorrectFormula(args_info.correct_flag);
- filter.Update();
-
- // this is the end my friend
- return 0;
-} // end main
+++ /dev/null
-#File clitkGuerreroVentilation.ggo
-package "clitkGuerreroVentilation"
-version "1.0"
-purpose "Compute the ventilation image from a motion compensated image and the reference (end-expiration) image"
-
-
-option "config" - "Config file" string no
-option "input" i "Input image filename" string yes
-option "ref" r "Reference image filename" string yes
-option "output" o "Output image base filename" string yes
-option "factor" f "Blood mass correction factor" double yes
-option "verbose" v "Verbose" flag off
-option "correct" c "Use the correct formula instead of the original one" flag off
+++ /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://www.centreleonberard.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
-===========================================================================**/
-/**
- -------------------------------------------------------------------
- * @file clitkGuerreroVentilationGenericFilter.cxx
- * @author Joël Schaerer
- * @date 20 April 2009
-
- * @brief
- -------------------------------------------------------------------*/
-
-#include "clitkGuerreroVentilationGenericFilter.h"
-#include <itkBinaryGuerreroFilter.h>
-#include <itkImageDuplicator.h>
-#include <itkExtractImageFilter.h>
-
-//--------------------------------------------------------------------
-clitk::GuerreroVentilationGenericFilter::GuerreroVentilationGenericFilter()
- :ImageToImageGenericFilter<Self>("GuerreroVentilationGenericFilter")
-{
- blood_mass_factor=1.;
- InitializeImageType<2>();
- InitializeImageType<3>();
-}
-//--------------------------------------------------------------------
-
-//--------------------------------------------------------------------
-template<unsigned int Dim>
-void clitk::GuerreroVentilationGenericFilter::InitializeImageType()
-{
- ADD_IMAGE_TYPE(Dim, short);
-}
-//--------------------------------------------------------------------
-
-
-//--------------------------------------------------------------------
-template<class ImageType>
-void clitk::GuerreroVentilationGenericFilter::UpdateWithInputImageType()
-{
-
- // Input should be 2
- assert(m_InputFilenames.size() == 2);
-
- // Reading input
- typedef ImageType InputImageType;
- typename InputImageType::Pointer input = this->template GetInput<InputImageType>(0);
- typename InputImageType::Pointer ref = this->template GetInput<InputImageType>(1);
-
- typedef itk::Image<float,InputImageType::ImageDimension> OutputImageType;
- // typename ImageType::Pointer input = clitk::readImage<ImageType>(mInputFilenames[0], mIOVerbose);
- //typename ImageType::Pointer ref = clitk::readImage<ImageType>(mInputFilenames[1], mIOVerbose);
-
- typedef itk::BinaryGuerreroFilter<ImageType,ImageType,OutputImageType> GFilterType;
- typename GFilterType::Pointer filter = GFilterType::New();
- filter->SetInput1(ref);
- filter->SetInput2(input);
- filter->SetBloodCorrectionFactor(blood_mass_factor);
- filter->SetUseCorrectFormula(use_correct_formula);
- filter->Update();
-
- this->SetNextOutput<OutputImageType>(filter->GetOutput());
- //clitk::writeImage<OutputImageType>(filter->GetOutput(), mOutputFilename, mIOVerbose);
- //std::cout << "Warning: removed " << filter->GetFunctor().aberant_voxels << " aberant voxels from the ventilation image"
- //<< std::endl;
-}
+++ /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://www.centreleonberard.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 clitkGuerreroVentilationGenericFilter_H
-#define clitkGuerreroVentilationGenericFilter_H
-/**
- -------------------------------------------------------------------
- * @file clitkGuerreroVentilationGenericFilter.h
- * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
- * @date 23 Feb 2008
- -------------------------------------------------------------------*/
-
-// clitk include
-#include "clitkImageToImageGenericFilter.h"
-
-// itk include
-#include "itkImage.h"
-#include "itkImageIOBase.h"
-#include "itkImageRegionIterator.h"
-#include "itkImageRegionConstIterator.h"
-
-namespace clitk {
-
- //--------------------------------------------------------------------
- class GuerreroVentilationGenericFilter :
- public ImageToImageGenericFilter<GuerreroVentilationGenericFilter> {
- public:
-
- // Constructor
- GuerreroVentilationGenericFilter();
- virtual ~GuerreroVentilationGenericFilter() {}
-
- // Types
- typedef GuerreroVentilationGenericFilter Self;
- typedef ImageToImageGenericFilterBase Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // New
- itkNewMacro(Self);
-
- // Set methods
- void SetBloodCorrectionFactor(double f) {blood_mass_factor=f;}
- void SetUseCorrectFormula(bool u) {use_correct_formula=u;}
-
- //--------------------------------------------------------------------
- // Main function called each time the filter is updated
- template<class InputImageType>
- void UpdateWithInputImageType();
-
- protected:
- template<unsigned int Dim> void InitializeImageType();
- //Parameters
- double blood_mass_factor;
- bool use_correct_formula;
-
- }; // end class GuerreroVentilationGenericFilter
-//--------------------------------------------------------------------
-
-} // end namespace
-//--------------------------------------------------------------------
-
-#endif //#define clitkGuerreroVentilationGenericFilter_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://www.centreleonberard.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 CLITKIMAGEEXTRACTLINE_CXX
-#define CLITKIMAGEEXTRACTLINE_CXX
-/**
- -------------------------------------------------
- * @file clitkImageExtractLine.cxx
- * @author David Sarrut <David.Sarrut@creatis.insa-lyon.fr>
- * @date 23 Feb 2008 08:37:53
- * @modified by Loïc Grevillot <Loic.Grevillot@creatis.insa-lyon.fr>
- * @date 10 March 2011
- * Option -I added, in order to integrate plans perpendicular to a line
-
- -------------------------------------------------*/
-
-// clitk include
-#include "clitkImageExtractLine_ggo.h"
-#include "clitkIO.h"
-#include "clitkImageCommon.h"
-#include "clitkCommon.h"
-#include <itkLineConstIterator.h>
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[])
-{
-
- // Init command line
- GGO(clitkImageExtractLine, args_info);
- CLITK_INIT;
-
- // Declare main types
- typedef float PixelType;
- const unsigned int Dimension=3;
- typedef itk::Image<PixelType, Dimension> ImageType;
- typedef itk::Size<Dimension> SizeType;
-
- // Check options
- if (args_info.firstIndex_given != Dimension) {
- std::cerr << "Please give " << Dimension << "values to --firstIndex option" << std::endl;
- exit(0);
- }
- if (args_info.lastIndex_given != Dimension) {
- std::cerr << "Please give " << Dimension << "values to --lastIndex option" << std::endl;
- exit(0);
- }
-
- // Read image
- ImageType::Pointer input = clitk::readImage<ImageType>(args_info.input_arg, args_info.verbose_flag);
-
- // Get first and last index
- typedef ImageType::IndexType IndexType;
- IndexType firstIndex;
- IndexType lastIndex;
- ImageType::SpacingType spacing = input->GetSpacing();
- double length = 0.0;
- for(unsigned int i=0; i<Dimension; i++) {
- firstIndex[i] = args_info.firstIndex_arg[i];
- lastIndex[i] = args_info.lastIndex_arg[i];
- if (args_info.mm_flag) {
- firstIndex[i] /= spacing[i];
- lastIndex[i] /= spacing[i];
- }
- length += pow(lastIndex[i]*spacing[i]-firstIndex[i]*spacing[i],2);
- }
- length = sqrt(length);
-
- // Loop
-// std::vector<double> depth;
-// std::vector<double> values;
-// itk::LineConstIterator<ImageType> iter(input, firstIndex, lastIndex);
-// iter.GoToBegin();
-// while (!iter.IsAtEnd()) {
-// values.push_back(iter.Get());
-// ++iter;
-// }
-// double step = length/values.size();
-
- std::vector<double> depth;
- std::vector<double> values;
- itk::LineConstIterator<ImageType> iter(input, firstIndex, lastIndex);
- int direction=0;
-
- // args_info.integral_arg=0, so, it does not compute the integral
- if (args_info.integral_arg==0){
- iter.GoToBegin();
- while (!iter.IsAtEnd()) {
- values.push_back(iter.Get());
- ++iter;
- }
- }
- // args_info.integral_arg=1, so, it computes the integral
- if (args_info.integral_arg!=0){
- int a=0, b=0, c=0;
- if (args_info.integralAxis_arg==0){
- a=1;
- b=0;
- c=2;
- }
- else if (args_info.integralAxis_arg==1){
- a=0;
- b=1;
- c=2;
- }
- else if (args_info.integralAxis_arg==2){
- a=2;
- b=0;
- c=1;
- }
- else {std::cout<<"Wrong axis"<<std::endl;
- exit(0);
- }
-
- length=(lastIndex[b]-firstIndex[b])*spacing[b];
-
- std::cout<<"The line is extracted along axis "<<args_info.integralAxis_arg<<std::endl;
- std::cout<<"The line is integrated between "<<args_info.firstIndex_arg[a]<<" and "<<args_info.lastIndex_arg[a]<<" along axis "<<a<<std::endl;
- std::cout<<"The line is integrated between "<<args_info.firstIndex_arg[c]<<" and "<<args_info.lastIndex_arg[c]<<" along axis "<<c<<std::endl;
-
- SizeType dim;
- dim=input->GetLargestPossibleRegion().GetSize();
- DD(dim);
- DD(direction);
-
- std::vector<double> val(dim[b]);
- for (size_t i=0; i<dim[b]; i++)
- val[i]=0;
-
- int k;
-
- for (int i=args_info.firstIndex_arg[a]; i<args_info.lastIndex_arg[a]; i++){
- for (int j=args_info.firstIndex_arg[c]; j<args_info.lastIndex_arg[c]; j++){
- // std::cout<<"i "<<i<<" j "<<j<<std::endl;
- k=0;
- firstIndex[a]=i;
- firstIndex[c]=j;
- lastIndex[a]=i;
- lastIndex[c]=j;
- // std::cout<<"A"<<std::endl;
- itk::LineConstIterator<ImageType> iter(input, firstIndex, lastIndex);
- iter.GoToBegin();
- // std::cout<<"B"<<std::endl;
- val[k]+=iter.Get();
- k++;
- // std::cout<<"C"<<std::endl;
- while (!iter.IsAtEnd()) {
- // std::cout<<"D "<<k<<std::endl;
- val[k]+=iter.Get();
- ++iter;
- k++;
- }
- }
- }
-
- for (unsigned int i=0; i<dim[b]; i++){
- values.push_back(val[i]);
- }
- }
-
- double step = length/values.size();
- DD(values.size());
-
- // If isocenter is used
- double isoDistance = 0.0;
- if (args_info.isocenter_given) { // isoCenter is in mm
- IndexType isoCenter;
- for(unsigned int i=0; i<Dimension; i++) {
- isoCenter[i] = args_info.isocenter_arg[i];
- isoDistance += pow(isoCenter[i] - firstIndex[i]*spacing[i],2);
- }
- DD(isoCenter);
- isoDistance = sqrt(isoDistance);
- DD(isoDistance);
- }
-
- // Write result
- std::ofstream os(args_info.output_arg);
- os << "# clitkImageExtractLine from " << args_info.input_arg << std::endl
- << "# \t firstIndex = " << firstIndex << std::endl
- << "# \t lastIndex = " << lastIndex << std::endl
- << "# \t nb values = " << values.size() << std::endl
- << "# \t length = " << length << std::endl
- << "# \t step = " << step << std::endl;
- if (args_info.depth_flag) {
- double lg = -isoDistance;
- for(unsigned int i=0; i<values.size(); i++) {
- os << lg << " " << values[i] << std::endl;
- lg += step;
- }
- os.close();
- } else {
- for(unsigned int i=0; i<values.size(); i++) {
- os << values[i] << std::endl;
- }
- os.close();
- }
-
- // this is the end my friend
- return 0;
-} // end main
-
-#endif //define CLITKIMAGEEXTRACTLINE_CXX
+++ /dev/null
-#File clitkImageExtractLine.ggo
-package "clitkImageExtractLine"
-version "1.0"
-purpose "Extract 1D values along a line (in voxels). 3D only."
-
-option "config" - "Config file" string no
-option "input" i "Input image filename" string yes
-option "output" o "Output txt filename" string yes
-option "verbose" v "Verbose" flag off
-
-option "firstIndex" f "First index value (in voxels)" int yes multiple
-option "lastIndex" l "Last index value (in voxels" int yes multiple
-option "integral" I "Integrate the image along a line" int no default = "0"
-option "integralAxis" a "Set the image integration axis" int no default = "0"
-
-option "mm" m "Last/first index are in mm" flag off
-
-option "isocenter" c "Set isocenter (in mm)" int no multiple
-option "depth" d "Write depth in output" flag off
+++ /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://www.centreleonberard.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 CLITKIMAGELOG_CXX
-#define CLITKIMAGELOG_CXX
-/**
- =================================================
- * @file clitkImageLog.cxx
- * @author Jef Vandemeulebroucke <Jef@creatis.insa-lyon.fr>
- * @date 04 April 2008 15:28:32
- *
- * @brief
- *
- * Take an inverse normalized log of the image intensity
- =================================================*/
-
-// clitk include
-#include "clitkImageLog_ggo.h"
-#include "clitkIO.h"
-#include "clitkCommon.h"
-
-// itk include
-#include "itkImageFileReader.h"
-#include "itkImageFileWriter.h"
-#include "itkImageRegionIterator.h"
-
-int main(int argc, char * argv[]) {
-
- // init command line
- GGO(clitkImageLog, args_info);
- CLITK_INIT;
-
- typedef float PixelType;
- const unsigned int Dimension=3;
- typedef itk::Image<PixelType, Dimension> ImageType;
- typedef itk::ImageFileReader<ImageType> ImageReaderType;
- typedef itk::ImageFileWriter<ImageType> ImageWriterType;
- typedef itk::ImageRegionIterator<ImageType> IteratorType;
-
- //Read input
- ImageReaderType::Pointer reader= ImageReaderType::New();
- reader->SetFileName(args_info.input_arg);
- reader->Update();
- ImageType::Pointer input = reader->GetOutput();
-
- //Create iterators
- IteratorType pi (input, input->GetLargestPossibleRegion());
- pi.GoToBegin();
-
- PixelType max=std::numeric_limits<unsigned short>::max();
-
- //Create output
- while(!pi.IsAtEnd())
- {
- if (pi.Get()< 0)
- {
- pi.Set(0.);
- }
- else
- {
- pi.Set(-log((PixelType)(max-pi.Get()+1)/(PixelType)max));
- }
- ++pi;
- }
-
- ImageWriterType::Pointer writer= ImageWriterType::New();
- writer->SetFileName(args_info.output_arg);
- writer->SetInput(input);
- writer->Update();
- return 0;
-}
-
-
-
-#endif /* end #define CLITKIMAGELOG_CXX */
+++ /dev/null
-# file clitkImageLog.ggo
-package "clitk"
-version "Perform a inverse normalized log on the image"
-
-option "config" - "Config file" string no
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "verbose" v "Verbose" flag off
-
+++ /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://www.centreleonberard.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
-===========================================================================*/
-#include "clitkLineProfile_ggo.h"
-#include "clitkLineProfileGenericFilter.h"
-
-
-bool verbose = false;
-
-template <unsigned int Dimension>
-void run(const args_info_clitkLineProfile& argsInfo);
-
-int main(int argc, char** argv)
-{
- GGO(clitkLineProfile, args_info);
-
- clitk::LineProfileGenericFilter::Pointer filter = clitk::LineProfileGenericFilter::New();
- filter->SetArgsInfo(args_info);
- filter->Update();
-
- return EXIT_SUCCESS;
-}
-
-
+++ /dev/null
-#File clitkLineProfile.ggo
-package "clitkLineProfile"
-version "1.0"
-purpose "Get the HU profile along the given line. Output to stdout."
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image" string yes
-option "p0" - "First point of the line" int no multiple default="0"
-option "p1" - "Second point of the line" int no multiple default="0"
-#option "output" o "Output file containing formated line points and values" string yes
+++ /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://www.centreleonberard.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
-===========================================================================*/
-#include "clitkLineProfileGenericFilter.h"
-
-namespace clitk
-{
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- LineProfileGenericFilter::LineProfileGenericFilter()
- : ImageToImageGenericFilter<Self>("Resample")
- {
- m_Verbose=false;
-
- InitializeImageType<2>();
- InitializeImageType<3>();
- //InitializeImageType<4>();
- }
- //--------------------------------------------------------------------
- //--------------------------------------------------------------------
- template<unsigned int Dim>
- void LineProfileGenericFilter::InitializeImageType()
- {
- ADD_DEFAULT_IMAGE_TYPES(Dim);
- //ADD_IMAGE_TYPE(Dim, short);
- }
- //--------------------------------------------------------------------
-
-}
\ No newline at end of file
+++ /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://www.centreleonberard.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 clitkLineProfileGenericFilter_h
-#define clitkLineProfileGenericFilter_h
-
-/* =================================================
- * @file clitkLineProfileGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkImageToImageGenericFilter.h"
-#include "clitkLineProfile_ggo.h"
-
-
-namespace clitk
-{
-
- class ITK_EXPORT LineProfileGenericFilter:
- public ImageToImageGenericFilter<LineProfileGenericFilter>
- {
- public:
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- LineProfileGenericFilter();
- ~LineProfileGenericFilter() {};
-
-
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef LineProfileGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( SetSpacingGenericFilter, LightObject );
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
- typedef args_info_clitkLineProfile ArgsInfoType;
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const ArgsInfoType & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- SetIOVerbose(m_Verbose);
- SetInputFilename(m_ArgsInfo.input_arg);
- }
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template<class InputImageType> void UpdateWithInputImageType();
-
- protected:
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- //template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
- template<unsigned int Dim> void InitializeImageType();
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkLineProfile m_ArgsInfo;
- bool m_Verbose;
-
- };
-}
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkLineProfileGenericFilter.txx"
-#endif
-
-#endif // clitkLineProfileGenericFilter_h
\ No newline at end of file
+++ /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://www.centreleonberard.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 clitkLineProfileGenericFilter_cxx
-#define clitkLineProfileGenericFilter_cxx
-
-/* =================================================
- * @file clitkLineProfileGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "itkBresenhamLine.h"
-
-namespace clitk
-{
-
-//-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- template<class InputImageType>
- void LineProfileGenericFilter::UpdateWithInputImageType()
- {
- typedef InputImageType ImageType;
-
- if (m_Verbose)
- std::cout << "LineProfileGenericFilter::UpdateWithInputImageType" << std::endl;
-
- // type checks
- if (m_ArgsInfo.p0_given != ImageType::ImageDimension ||
- m_ArgsInfo.p1_given != ImageType::ImageDimension)
- throw std::logic_error("Dimension of input points and image do not match.");
-
- typename ImageType::Pointer image = this->template GetInput<InputImageType>(0);
- typename ImageType::RegionType region = image->GetLargestPossibleRegion();
-
- typedef typename ImageType::PointType PointType;
- PointType p0, p1;
- for (unsigned int i = 0; i < ImageType::ImageDimension; i++) {
- p0[i] = m_ArgsInfo.p0_arg[i];
- p1[i] = m_ArgsInfo.p1_arg[i];
- }
-
- // compute params of line between p0 and p1
- // length (magnitude) must be an integer value, so it's
- // the max distance along one the axes plus one to account
- // for the last point.
- typedef itk::BresenhamLine<ImageType::ImageDimension> LineType;
- typename LineType::LType direction = p1 - p0;
- typename LineType::LType::RealValueType mag = 0;
- for (unsigned int i = 0; i < ImageType::ImageDimension; i++) {
- if (direction[i] > mag)
- mag = direction[i];
- }
- mag++;
-
- if (m_Verbose)
- std::cout << "Building line with direction = " << direction << " and length = " << mag << "..." << std::endl;
-
- // build the line itself
- LineType line;
- typename LineType::OffsetArray offsets;
- offsets = line.BuildLine(direction, mag);
-
- if (m_Verbose)
- std::cout << "Line has " << offsets.size() << " points" << std::endl;
-
- // fill the output vectors
- typedef typename ImageType::PixelType PixelType;
- typedef typename ImageType::OffsetType OffsetType;
- typedef typename ImageType::IndexType IndexType;
- typedef std::vector<IndexType> IndexArrayType;
- typedef std::vector<PixelType> ValueArrayType;
-
- IndexType index0, index1;
- for (unsigned int i = 0; i < ImageType::ImageDimension; i++) {
- index0[i] = m_ArgsInfo.p0_arg[i];
- index1[i] = m_ArgsInfo.p1_arg[i];
- }
-
- if (m_Verbose)
- std::cout << "Getting profile along line..." << std::endl;
-
- IndexType index;
- IndexArrayType line_indices;
- ValueArrayType line_values;
- for (size_t i = 0; i < offsets.size(); i++)
- {
- index = index0 + offsets[i];
- if (m_Verbose) {
- std::cout << "index " << i << " = " << index << std::endl;
- }
-
- if (region.IsInside(index)) {
- if (m_Verbose)
- std::cout << "value " << i << " = " << image->GetPixel(index) << std::endl;
-
- line_indices.push_back(index);
- line_values.push_back(image->GetPixel(index));
- }
- else if (m_Verbose)
- std::cout << "index outside image" << std::endl;
- }
-
- if (m_Verbose) {
- std::cout << "I bring to you The Computed Points!" << std::endl;
- }
-
- for (size_t i = 0; i < line_indices.size(); i++) {
- std::cout << line_indices[i] << " " << line_values[i] << std::endl;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkLineProfileGenericFilter_cxx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkPermuteAxes.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkPermuteAxes_ggo.h"
-#include "clitkIO.h"
-#include "clitkPermuteAxesGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkPermuteAxes, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::PermuteAxesGenericFilter::Pointer genericFilter=clitk::PermuteAxesGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkPermuteAxes.ggo
-package "clitkPermuteAxes"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "order" - "The new order of the axes (n comma separated values [o,N])" int multiple yes
-
-
+++ /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://www.centreleonberard.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 clitkPermuteAxesGenericFilter_cxx
-#define clitkPermuteAxesGenericFilter_cxx
-
-/* =================================================
- * @file clitkPermuteAxesGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkPermuteAxesGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- PermuteAxesGenericFilter::PermuteAxesGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void PermuteAxesGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkPermuteAxesGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkPermuteAxesGenericFilter_h
-#define clitkPermuteAxesGenericFilter_h
-
-/* =================================================
- * @file clitkPermuteAxesGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkPermuteAxes_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkPermuteAxesImageFilter.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT PermuteAxesGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef PermuteAxesGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( PermuteAxesGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkPermuteAxes & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- PermuteAxesGenericFilter();
- ~PermuteAxesGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkPermuteAxes m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkPermuteAxesGenericFilter.txx"
-#endif
-
-#endif // #define clitkPermuteAxesGenericFilter_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://www.centreleonberard.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 clitkPermuteAxesGenericFilter_txx
-#define clitkPermuteAxesGenericFilter_txx
-
-/* =================================================
- * @file clitkPermuteAxesGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- PermuteAxesGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- PermuteAxesGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typedef itk::PermuteAxesImageFilter<InputImageType> PermuteFilterType;
- typename PermuteFilterType::Pointer permuteFilter=PermuteFilterType::New();
- permuteFilter->SetInput(input);
- typename PermuteFilterType::PermuteOrderArrayType order;
-
- if(m_ArgsInfo.order_given != Dimension)
- {
- std::cerr<<"Error: Number of order parameters is different from image dimension!"<<std::endl;
- return;
- }
-
-
- for (unsigned int i=0;i<Dimension; i++)
- order[i]=m_ArgsInfo.order_arg[i];
-
- permuteFilter->SetOrder(order);
- permuteFilter->Update();
- typename OutputImageType::Pointer output =permuteFilter->GetOutput();
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkPermuteAxesGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkSetDirection.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkSetDirection_ggo.h"
-#include "clitkIO.h"
-#include "clitkSetDirectionGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkSetDirection, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::SetDirectionGenericFilter::Pointer genericFilter=clitk::SetDirectionGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkSetDirection.ggo
-package "clitkSetDirection"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "direction" d "Direction cosine matrix (defaults to identity)" double multiple no
-
+++ /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://www.centreleonberard.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 clitkSetDirectionGenericFilter_cxx
-#define clitkSetDirectionGenericFilter_cxx
-
-/* =================================================
- * @file clitkSetDirectionGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkSetDirectionGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- SetDirectionGenericFilter::SetDirectionGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void SetDirectionGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType);
- else if(Dimension==3) UpdateWithDim<3>(PixelType);
- else if (Dimension==4)UpdateWithDim<4>(PixelType);
- else
- {
- std::cout<<"Error, Only for 2,3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkSetDirectionGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkSetDirectionGenericFilter_h
-#define clitkSetDirectionGenericFilter_h
-
-/* =================================================
- * @file clitkSetDirectionGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkSetDirection_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT SetDirectionGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef SetDirectionGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( SetDirectionGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkSetDirection & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- SetDirectionGenericFilter();
- ~SetDirectionGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkSetDirection m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkSetDirectionGenericFilter.txx"
-#endif
-
-#endif // #define clitkSetDirectionGenericFilter_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://www.centreleonberard.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 clitkSetDirectionGenericFilter_txx
-#define clitkSetDirectionGenericFilter_txx
-
-/* =================================================
- * @file clitkSetDirectionGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- SetDirectionGenericFilter::UpdateWithDim(std::string PixelType)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<< PixelType<<"..."<<std::endl;
-
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- SetDirectionGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typename InputImageType::DirectionType direction;
- direction.SetIdentity();
- if(m_ArgsInfo.direction_given==Dimension*Dimension)
- for (unsigned int i=0;i<Dimension;i++)
- for (unsigned int j=0;j<Dimension;j++)
- direction[i][j]=m_ArgsInfo.direction_arg[i+j];
- input->SetDirection(direction);
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(input);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkSetDirectionGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkSetOrigin.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkSetOrigin_ggo.h"
-#include "clitkIO.h"
-#include "clitkSetOriginGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkSetOrigin, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::SetOriginGenericFilter::Pointer genericFilter=clitk::SetOriginGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkSetOrigin.ggo
-package "clitkSetOrigin"
-version "1.0"
-purpose "Set the origin field of a generic image"
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "like" l "Like image filename" string no
-option "origin" - "Origin" double multiple no default="0"
+++ /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://www.centreleonberard.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 clitkSetOriginGenericFilter_cxx
-#define clitkSetOriginGenericFilter_cxx
-
-/* =================================================
- * @file clitkSetOriginGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkSetOriginGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- SetOriginGenericFilter::SetOriginGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void SetOriginGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension, Components;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
- else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
- else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
- else
- {
- std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkSetOriginGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkSetOriginGenericFilter_h
-#define clitkSetOriginGenericFilter_h
-
-/* =================================================
- * @file clitkSetOriginGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkSetOrigin_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT SetOriginGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef SetOriginGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( SetOriginGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkSetOrigin & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- SetOriginGenericFilter();
- ~SetOriginGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, int Components);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkSetOrigin m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkSetOriginGenericFilter.txx"
-#endif
-
-#endif // #define clitkSetOriginGenericFilter_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://www.centreleonberard.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 clitkSetOriginGenericFilter_txx
-#define clitkSetOriginGenericFilter_txx
-
-/* =================================================
- * @file clitkSetOriginGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- SetOriginGenericFilter::UpdateWithDim(std::string PixelType, int Components)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
-
- if (Components==1)
- {
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
- else if (Components==3)
- {
- if (m_Verbose) std::cout << "Launching transform in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
- UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
- }
-
- else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
-
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- SetOriginGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Origin
- typename InputImageType::PointType origin;
- origin.Fill(0.0);
-
- // Like?
- if (m_ArgsInfo.like_given)
- {
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer likeReader = InputReaderType::New();
- likeReader->SetFileName( m_ArgsInfo.like_arg);
- likeReader->Update();
- typename InputImageType::Pointer like= likeReader->GetOutput();
- origin=like->GetOrigin();
- }
- else
- {
- if (m_ArgsInfo.origin_given==Dimension)
- for(unsigned int i=0; i<Dimension;i++)
- origin[i]=m_ArgsInfo.origin_arg[i];
- else
- for(unsigned int i=0; i<Dimension;i++)
- origin[i]=m_ArgsInfo.origin_arg[0];
- }
- input->SetOrigin(origin);
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(input);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkSetOriginGenericFilter_txx
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkSetSpacing.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkSetSpacing_ggo.h"
-#include "clitkIO.h"
-#include "clitkSetSpacingGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkSetSpacing, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::SetSpacingGenericFilter::Pointer genericFilter=clitk::SetSpacingGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkSetSpacing.ggo
-package "clitkSetSpacing"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-option "like" l "Like image filename" string no
-option "spacing" s "Spacing" double no multiple default="1"
-
-
+++ /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://www.centreleonberard.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 clitkSetSpacingGenericFilter_cxx
-#define clitkSetSpacingGenericFilter_cxx
-
-/* =================================================
- * @file clitkSetSpacingGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkSetSpacingGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- SetSpacingGenericFilter::SetSpacingGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void SetSpacingGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension, Components;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
- else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
- else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
- else
- {
- std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkSetSpacingGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkSetSpacingGenericFilter_h
-#define clitkSetSpacingGenericFilter_h
-
-/* =================================================
- * @file clitkSetSpacingGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkSetSpacing_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT SetSpacingGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef SetSpacingGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( SetSpacingGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkSetSpacing & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- SetSpacingGenericFilter();
- ~SetSpacingGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkSetSpacing m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkSetSpacingGenericFilter.txx"
-#endif
-
-#endif // #define clitkSetSpacingGenericFilter_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://www.centreleonberard.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 clitkSetSpacingGenericFilter_txx
-#define clitkSetSpacingGenericFilter_txx
-
-/* =================================================
- * @file clitkSetSpacingGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- SetSpacingGenericFilter::UpdateWithDim(std::string PixelType , unsigned int Components)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
-
- if (Components==1)
- {
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
- else if (Components==3)
- {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
- UpdateWithDimAndPixelType<Dimension, itk::Vector<float, 3> >();
- }
-
- else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
- }
-
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- SetSpacingGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typename InputImageType::SpacingType spacing;
- spacing.Fill(1.0);
-
- // Like?
- if (m_ArgsInfo.like_given)
- {
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer likeReader = InputReaderType::New();
- likeReader->SetFileName( m_ArgsInfo.like_arg);
- likeReader->Update();
- typename InputImageType::Pointer like= likeReader->GetOutput();
- spacing=like->GetSpacing();
- }
- else
- {
- if (m_ArgsInfo.spacing_given==Dimension)
- for(unsigned int i=0; i<Dimension;i++)
- spacing[i]=m_ArgsInfo.spacing_arg[i];
- else
- for(unsigned int i=0; i<Dimension;i++)
- spacing[i]=m_ArgsInfo.spacing_arg[0];
- }
- input->SetSpacing(spacing);
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(input);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkSetSpacingGenericFilter_txx
+++ /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://www.centreleonberard.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 CLITKVFMERGE_CXX
-#define CLITKVFMERGE_CXX
-
-/**
- * @file clitkVFMerge.cxx
- * @author Jef Vandemeulebroucke <jefvdmb@gmail.com>
- * @date June 15 10:14:53 2007
- *
- * @brief Read in one VF (ex mhd, vf) and write to another. Transforming from mm to voxels needed for the vf format is implemented in clitkVfImageIO.cxx .
- *
- *
- */
-
-// clitk include
-#include "clitkVFMerge_ggo.h"
-#include "clitkIO.h"
-#include "clitkImageCommon.h"
-#include "clitkCommon.h"
-
-// itk include
-#include "itkImageFileWriter.h"
-#include <iostream>
-#include "itkImageFileReader.h"
-
-int main( int argc, char *argv[] )
-{
-
- // Init command line
- GGO(clitkVFMerge, args_info);
- CLITK_INIT;
-
- const unsigned int SpaceDimension = 3;
- const unsigned int ModelDimension = 4;
- typedef itk::Vector< float, SpaceDimension > Displacement;
- typedef itk::Image< Displacement, SpaceDimension > DeformationFieldType;
- typedef itk::Image< Displacement, ModelDimension > DynamicDeformationFieldType;
- typedef itk::ImageFileReader< DeformationFieldType > DeformationFieldReaderType;
- typedef itk::ImageFileWriter< DynamicDeformationFieldType > DynamicDeformationFieldWriterType;
-
-
-//declare the dynamic
- DynamicDeformationFieldType::Pointer dynamicDeformationField=DynamicDeformationFieldType::New();
-
-
-//declare their iterators
- typedef itk::ImageRegionIterator< DynamicDeformationFieldType> DynamicDeformationFieldIteratorType;
- DynamicDeformationFieldIteratorType *dynamicIteratorPointer= new DynamicDeformationFieldIteratorType;
-
- for (unsigned int i=0 ; i< args_info.inputs_num ; i ++) {
- //read in the deformation field i
- DeformationFieldReaderType::Pointer deformationFieldReader = DeformationFieldReaderType::New();
- deformationFieldReader->SetFileName( args_info.inputs[i]);
- if (args_info.verbose_flag) std::cout<<"Reading VF number "<< i+1 << std::endl;
- deformationFieldReader->Update();
- DeformationFieldType::Pointer currentDeformationField = deformationFieldReader->GetOutput();
-
- //create an iterator for the current deformation field
- typedef itk::ImageRegionIterator<DeformationFieldType> FieldIteratorType;
- FieldIteratorType fieldIterator(currentDeformationField, currentDeformationField->GetLargestPossibleRegion());
-
- //Allocate memory for the dynamic components
- if (i==0) {
- DynamicDeformationFieldType::RegionType dynamicDeformationFieldRegion;
- DynamicDeformationFieldType::RegionType::SizeType dynamicDeformationFieldSize;
- DeformationFieldType::RegionType::SizeType deformationFieldSize;
- deformationFieldSize= currentDeformationField->GetLargestPossibleRegion().GetSize();
- dynamicDeformationFieldSize[0]=deformationFieldSize[0];
- dynamicDeformationFieldSize[1]=deformationFieldSize[1];
- dynamicDeformationFieldSize[2]=deformationFieldSize[2];
- dynamicDeformationFieldSize[3]=args_info.inputs_num;
- dynamicDeformationFieldRegion.SetSize(dynamicDeformationFieldSize);
- DynamicDeformationFieldType::IndexType start;
- start.Fill(0);
- dynamicDeformationFieldRegion.SetIndex(start);
- dynamicDeformationField->SetRegions(dynamicDeformationFieldRegion);
- dynamicDeformationField->Allocate();
-
-
- //Set the spacing
- DeformationFieldType::SpacingType spacing= currentDeformationField->GetSpacing();
- DynamicDeformationFieldType::SpacingType dynamicSpacing;
- dynamicSpacing[0]=spacing[0];
- dynamicSpacing[1]=spacing[1];
- dynamicSpacing[2]=spacing[2];
- dynamicSpacing[3]=args_info.spacing_arg; //JV par exemple
- dynamicDeformationField->SetSpacing(dynamicSpacing);
- DynamicDeformationFieldType::PointType origin;
- origin[0]=args_info.xorigin_arg;
- origin[1]=args_info.yorigin_arg;
- origin[2]=args_info.zorigin_arg;
- origin[3]=0; //temporal origin is always 0
- dynamicDeformationField->SetOrigin(origin);
-
- // Creating iterators for the currentDeformationField and the DynamicDeformationField
- DynamicDeformationFieldIteratorType *dynamicIterator= new DynamicDeformationFieldIteratorType(dynamicDeformationField, dynamicDeformationField->GetLargestPossibleRegion());
- dynamicIteratorPointer=dynamicIterator;
- dynamicIteratorPointer->GoToBegin();
- }
- if (args_info.verbose_flag) std::cout<<"Merging VF number "<< i+1 << std::endl;
- //Copy the current component of the input into dynamicDeformationFieldComponent
- fieldIterator.GoToBegin();
- while(!fieldIterator.IsAtEnd()) {
- dynamicIteratorPointer->Set(fieldIterator.Get());
- ++fieldIterator;
- ++(*dynamicIteratorPointer);
- }
- }
-
-
-//Write the vector field
- DynamicDeformationFieldWriterType::Pointer writer = DynamicDeformationFieldWriterType::New();
- writer->SetInput( dynamicDeformationField );
- writer->SetFileName( args_info.output_arg );
- if (args_info.verbose_flag) std::cout<<"Writing the dynamic VF"<< std::endl;
-
-
- try {
-
- writer->Update( );
- } catch( itk::ExceptionObject & excp ) {
- std::cerr << "Problem writing the output file" << std::endl;
- std::cerr << excp << std::endl;
- return EXIT_FAILURE;
- }
- return EXIT_SUCCESS;
-}
-#endif
-
-
+++ /dev/null
-#File clitkVFMerge.ggo
-#Author: Jef Vandemeulebroucke <jefvdmb@gmail.com>
-#Date : Tue 15 June 16.35
-
-package "clitk"
-version "Read a bunch of vector fields (.mhd, .vf, ..) and turn them into a higher dimension vector field (.mhd, ...)"
-
-option "config" - "Config file" string no
-option "output" o "Output VF filename" string yes
-option "spacing" s "Spacing for the fourth dimension" float no default="1"
-option "verbose" v "Verbose" flag off
-option "xorigin" x "Set the x origin of the output vf" float default="0."
-option "yorigin" y "Set the y origin of the output vf" float default="0."
-option "zorigin" z "Set the z origin of the output vf" float default="0."
+++ /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://www.centreleonberard.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
-===========================================================================**/
-
-/* =================================================
- * @file clitkValuesToBSplineCoefficients.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk
-#include "clitkValuesToBSplineCoefficients_ggo.h"
-#include "clitkIO.h"
-#include "clitkValuesToBSplineCoefficientsGenericFilter.h"
-
-
-//--------------------------------------------------------------------
-int main(int argc, char * argv[]) {
-
- // Init command line
- GGO(clitkValuesToBSplineCoefficients, args_info);
- CLITK_INIT;
-
- // Filter
- clitk::ValuesToBSplineCoefficientsGenericFilter::Pointer genericFilter=clitk::ValuesToBSplineCoefficientsGenericFilter::New();
-
- genericFilter->SetArgsInfo(args_info);
- genericFilter->Update();
-
- return EXIT_SUCCESS;
-}// end main
-
-//--------------------------------------------------------------------
+++ /dev/null
-#File clitkValuesToBSplineCoefficients.ggo
-package "clitkValuesToBSplineCoefficients"
-version "1.0"
-purpose ""
-
-option "config" - "Config file" string no
-option "verbose" v "Verbose" flag off
-
-option "input" i "Input image filename" string yes
-option "output" o "Output image filename" string yes
-
-option "order" - "Order of the BSpline coefficients" int no default="3"
+++ /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://www.centreleonberard.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 clitkValuesToBSplineCoefficientsGenericFilter_cxx
-#define clitkValuesToBSplineCoefficientsGenericFilter_cxx
-
-/* =================================================
- * @file clitkValuesToBSplineCoefficientsGenericFilter.cxx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-#include "clitkValuesToBSplineCoefficientsGenericFilter.h"
-
-
-namespace clitk
-{
-
-
- //-----------------------------------------------------------
- // Constructor
- //-----------------------------------------------------------
- ValuesToBSplineCoefficientsGenericFilter::ValuesToBSplineCoefficientsGenericFilter()
- {
- m_Verbose=false;
- m_InputFileName="";
- }
-
-
- //-----------------------------------------------------------
- // Update
- //-----------------------------------------------------------
- void ValuesToBSplineCoefficientsGenericFilter::Update()
- {
- // Read the Dimension and PixelType
- int Dimension, Components;
- std::string PixelType;
- ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType, Components);
-
-
- // Call UpdateWithDim
- if(Dimension==2) UpdateWithDim<2>(PixelType, Components);
- else if(Dimension==3) UpdateWithDim<3>(PixelType, Components);
- else if (Dimension==4)UpdateWithDim<4>(PixelType, Components);
- else
- {
- std::cout<<"Error, Only for 2, 3 or 4 Dimensions!!!"<<std::endl ;
- return;
- }
- }
-
-
-} //end clitk
-
-#endif //#define clitkValuesToBSplineCoefficientsGenericFilter_cxx
+++ /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://www.centreleonberard.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 clitkValuesToBSplineCoefficientsGenericFilter_h
-#define clitkValuesToBSplineCoefficientsGenericFilter_h
-
-/* =================================================
- * @file clitkValuesToBSplineCoefficientsGenericFilter.h
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-// clitk include
-#include "clitkIO.h"
-#include "clitkCommon.h"
-#include "clitkImageCommon.h"
-#include "clitkValuesToBSplineCoefficients_ggo.h"
-
-//itk include
-#include "itkLightObject.h"
-#include "itkBSplineDecompositionImageFilter.h"
-#include "clitkVectorBSplineDecompositionImageFilter.h"
-
-namespace clitk
-{
-
-
- class ITK_EXPORT ValuesToBSplineCoefficientsGenericFilter : public itk::LightObject
- {
- public:
- //----------------------------------------
- // ITK
- //----------------------------------------
- typedef ValuesToBSplineCoefficientsGenericFilter Self;
- typedef itk::LightObject Superclass;
- typedef itk::SmartPointer<Self> Pointer;
- typedef itk::SmartPointer<const Self> ConstPointer;
-
- // Method for creation through the object factory
- itkNewMacro(Self);
-
- // Run-time type information (and related methods)
- itkTypeMacro( ValuesToBSplineCoefficientsGenericFilter, LightObject );
-
-
- //----------------------------------------
- // Typedefs
- //----------------------------------------
-
-
- //----------------------------------------
- // Set & Get
- //----------------------------------------
- void SetArgsInfo(const args_info_clitkValuesToBSplineCoefficients & a)
- {
- m_ArgsInfo=a;
- m_Verbose=m_ArgsInfo.verbose_flag;
- m_InputFileName=m_ArgsInfo.input_arg;
- }
-
-
- //----------------------------------------
- // Update
- //----------------------------------------
- void Update();
-
- protected:
-
- //----------------------------------------
- // Constructor & Destructor
- //----------------------------------------
- ValuesToBSplineCoefficientsGenericFilter();
- ~ValuesToBSplineCoefficientsGenericFilter() {};
-
-
- //----------------------------------------
- // Templated members
- //----------------------------------------
- template <unsigned int Dimension> void UpdateWithDim(std::string PixelType, unsigned int Components);
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndPixelType();
- template <unsigned int Dimension, class PixelType> void UpdateWithDimAndVectorType();
-
-
- //----------------------------------------
- // Data members
- //----------------------------------------
- args_info_clitkValuesToBSplineCoefficients m_ArgsInfo;
- bool m_Verbose;
- std::string m_InputFileName;
-
- };
-
-
-} // end namespace clitk
-
-#ifndef ITK_MANUAL_INSTANTIATION
-#include "clitkValuesToBSplineCoefficientsGenericFilter.txx"
-#endif
-
-#endif // #define clitkValuesToBSplineCoefficientsGenericFilter_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://www.centreleonberard.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 clitkValuesToBSplineCoefficientsGenericFilter_txx
-#define clitkValuesToBSplineCoefficientsGenericFilter_txx
-
-/* =================================================
- * @file clitkValuesToBSplineCoefficientsGenericFilter.txx
- * @author
- * @date
- *
- * @brief
- *
- ===================================================*/
-
-
-namespace clitk
-{
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions
- //-------------------------------------------------------------------
- template<unsigned int Dimension>
- void
- ValuesToBSplineCoefficientsGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components)
- {
- if (m_Verbose) std::cout << "Image was detected to be "<<Dimension<<"D and "<<Components<<" component(s) of "<< PixelType<<"..."<<std::endl;
-
- if (Components==1)
- {
- if(PixelType == "short"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed short..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, signed short>();
- }
- // else if(PixelType == "unsigned_short"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, unsigned short>();
- // }
-
- else if (PixelType == "unsigned_char"){
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, unsigned char>();
- }
-
- // else if (PixelType == "char"){
- // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl;
- // UpdateWithDimAndPixelType<Dimension, signed char>();
- // }
- else {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl;
- UpdateWithDimAndPixelType<Dimension, float>();
- }
- }
-
- else if (Components==3)
- {
- if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl;
- UpdateWithDimAndVectorType<Dimension, itk::Vector<float, 3> >();
- }
-
- else std::cerr<<"Number of components is "<<Components<<", not supported!"<<std::endl;
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the pixeltype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- ValuesToBSplineCoefficientsGenericFilter::UpdateWithDimAndPixelType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typedef itk::BSplineDecompositionImageFilter<InputImageType, OutputImageType> FilterType;
- typename FilterType::Pointer filter=FilterType::New();
- filter->SetInput(input);
- filter->SetSplineOrder(m_ArgsInfo.order_arg);
- filter->Update();
- typename OutputImageType::Pointer output=filter->GetOutput();
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
- //-------------------------------------------------------------------
- // Update with the number of dimensions and the Vectortype
- //-------------------------------------------------------------------
- template <unsigned int Dimension, class PixelType>
- void
- ValuesToBSplineCoefficientsGenericFilter::UpdateWithDimAndVectorType()
- {
-
- // ImageTypes
- typedef itk::Image<PixelType, Dimension> InputImageType;
- typedef itk::Image<PixelType, Dimension> OutputImageType;
-
- // Read the input
- typedef itk::ImageFileReader<InputImageType> InputReaderType;
- typename InputReaderType::Pointer reader = InputReaderType::New();
- reader->SetFileName( m_InputFileName);
- reader->Update();
- typename InputImageType::Pointer input= reader->GetOutput();
-
- // Filter
- typedef clitk::VectorBSplineDecompositionImageFilter<InputImageType, OutputImageType> FilterType;
- typename FilterType::Pointer filter=FilterType::New();
- filter->SetInput(input);
- filter->SetSplineOrder(m_ArgsInfo.order_arg);
- filter->Update();
- typename OutputImageType::Pointer output=filter->GetOutput();
-
- // Output
- typedef itk::ImageFileWriter<OutputImageType> WriterType;
- typename WriterType::Pointer writer = WriterType::New();
- writer->SetFileName(m_ArgsInfo.output_arg);
- writer->SetInput(output);
- writer->Update();
-
- }
-
-
-}//end clitk
-
-#endif //#define clitkValuesToBSplineCoefficientsGenericFilter_txx