X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkInvertVFGenericFilter.txx;h=b9641fad1f376cf85d7b046f36f95e01958b734b;hb=573d80d0f7a17607d2ee883c21c940c0ba020282;hp=c2bcc274e0377d37f5bd4a6d6d4067d870211580;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/tools/clitkInvertVFGenericFilter.txx b/tools/clitkInvertVFGenericFilter.txx index c2bcc27..b9641fa 100644 --- a/tools/clitkInvertVFGenericFilter.txx +++ b/tools/clitkInvertVFGenericFilter.txx @@ -1,166 +1,178 @@ +/*========================================================================= + 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 clitkInvertVFGenericFilter_txx #define clitkInvertVFGenericFilter_txx /* ================================================= * @file clitkInvertVFGenericFilter.txx - * @author - * @date - * - * @brief - * + * @author + * @date + * + * @brief + * ===================================================*/ namespace clitk { - //----------------------------------------------------------- - // Constructor - //----------------------------------------------------------- - template - InvertVFGenericFilter::InvertVFGenericFilter() - { - m_Verbose=false; - m_InputFileName=""; - } +//----------------------------------------------------------- +// Constructor +//----------------------------------------------------------- +template +InvertVFGenericFilter::InvertVFGenericFilter() +{ + m_Verbose=false; + m_InputFileName=""; +} + + +//----------------------------------------------------------- +// Update +//----------------------------------------------------------- +template +void InvertVFGenericFilter::Update() +{ + // Read the Dimension and PixelType + int Dimension; + std::string PixelType; + ReadImageDimensionAndPixelType(m_InputFileName, Dimension, PixelType); - //----------------------------------------------------------- - // Update - //----------------------------------------------------------- - template - void InvertVFGenericFilter::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!!!"<(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!!!"< +template +void +InvertVFGenericFilter::UpdateWithDim(std::string PixelType) +{ + if (m_Verbose) std::cout << "Image was detected to be "<(); + // } + // else if(PixelType == "unsigned_short"){ + // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl; + // UpdateWithDimAndPixelType(); + // } + + // else if (PixelType == "unsigned_char"){ + // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl; + // UpdateWithDimAndPixelType(); + // } + + // else if (PixelType == "char"){ + // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl; + // UpdateWithDimAndPixelType(); + // } + // else { + if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl; + UpdateWithDimAndPixelType >(); + // } +} - //------------------------------------------------------------------- - // Update with the number of dimensions - //------------------------------------------------------------------- - template - template - void - InvertVFGenericFilter::UpdateWithDim(std::string PixelType) - { - if (m_Verbose) std::cout << "Image was detected to be "<(); - // } - // else if(PixelType == "unsigned_short"){ - // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_short..." << std::endl; - // UpdateWithDimAndPixelType(); - // } - - // else if (PixelType == "unsigned_char"){ - // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and unsigned_char..." << std::endl; - // UpdateWithDimAndPixelType(); - // } - - // else if (PixelType == "char"){ - // if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and signed_char..." << std::endl; - // UpdateWithDimAndPixelType(); - // } - // else { - if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and float..." << std::endl; - UpdateWithDimAndPixelType >(); - // } + +//------------------------------------------------------------------- +// Update with the number of dimensions and the pixeltype +//------------------------------------------------------------------- +template +template +void +InvertVFGenericFilter::UpdateWithDimAndPixelType() +{ + + // ImageTypes + typedef itk::Image InputImageType; + typedef itk::Image OutputImageType; + + // Read the input + typedef itk::ImageFileReader InputReaderType; + typename InputReaderType::Pointer reader = InputReaderType::New(); + reader->SetFileName( m_InputFileName); + reader->Update(); + typename InputImageType::Pointer input= reader->GetOutput(); + + // Filter + typename OutputImageType::Pointer output; + switch (m_ArgsInfo.type_arg) { + + // clitk filter + case 0: { + // Create the InvertVFFilter + typedef clitk::InvertVFFilter FilterType; + typename FilterType::Pointer filter =FilterType::New(); + filter->SetInput(input); + filter->SetVerbose(m_Verbose); + if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg); + if (m_ArgsInfo.pad_given) { + PixelType pad; + if (m_ArgsInfo.pad_given != (pad.GetNumberOfComponents()) ) + pad.Fill(m_ArgsInfo.pad_arg[0]); + else + for(unsigned int i=0; iSetThreadSafe(m_ArgsInfo.threadSafe_flag); + filter->Update(); + output=filter->GetOutput(); + + break; } + case 1: { + // Create the InverseDeformationFieldFilter + typedef itk::InverseDeformationFieldImageFilter FilterType; + typename FilterType::Pointer filter =FilterType::New(); + filter->SetInput(input); + filter->SetOutputOrigin(input->GetOrigin()); + filter->SetOutputSpacing(input->GetSpacing()); + filter->SetSize(input->GetLargestPossibleRegion().GetSize()); + filter->SetSubsamplingFactor(m_ArgsInfo.sampling_arg); + filter->Update(); + output=filter->GetOutput(); - //------------------------------------------------------------------- - // Update with the number of dimensions and the pixeltype - //------------------------------------------------------------------- - template - template - void - InvertVFGenericFilter::UpdateWithDimAndPixelType() - { - - // ImageTypes - typedef itk::Image InputImageType; - typedef itk::Image OutputImageType; - - // Read the input - typedef itk::ImageFileReader InputReaderType; - typename InputReaderType::Pointer reader = InputReaderType::New(); - reader->SetFileName( m_InputFileName); - reader->Update(); - typename InputImageType::Pointer input= reader->GetOutput(); - - // Filter - typename OutputImageType::Pointer output; - switch (m_ArgsInfo.type_arg) - { - - // clitk filter - case 0: - { - // Create the InvertVFFilter - typedef clitk::InvertVFFilter FilterType; - typename FilterType::Pointer filter =FilterType::New(); - filter->SetInput(input); - filter->SetVerbose(m_Verbose); - if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg); - if (m_ArgsInfo.pad_given) - { - PixelType pad; - if (m_ArgsInfo.pad_given != (pad.GetNumberOfComponents()) ) - pad.Fill(m_ArgsInfo.pad_arg[0]); - else - for(unsigned int i=0; iSetThreadSafe(m_ArgsInfo.threadSafe_flag); - filter->Update(); - output=filter->GetOutput(); - - break; - } - - case 1: - { - // Create the InverseDeformationFieldFilter - typedef itk::InverseDeformationFieldImageFilter FilterType; - typename FilterType::Pointer filter =FilterType::New(); - filter->SetInput(input); - filter->SetOutputOrigin(input->GetOrigin()); - filter->SetOutputSpacing(input->GetSpacing()); - filter->SetSize(input->GetLargestPossibleRegion().GetSize()); - filter->SetSubsamplingFactor(m_ArgsInfo.sampling_arg); - filter->Update(); - output=filter->GetOutput(); - - break; - } - - } - - // Output - typedef itk::ImageFileWriter WriterType; - typename WriterType::Pointer writer = WriterType::New(); - writer->SetFileName(m_ArgsInfo.output_arg); - writer->SetInput(output); - writer->Update(); - + break; } - - + + } + + // Output + typedef itk::ImageFileWriter WriterType; + typename WriterType::Pointer writer = WriterType::New(); + writer->SetFileName(m_ArgsInfo.output_arg); + writer->SetInput(output); + writer->Update(); + +} + + }//end clitk - + #endif //#define clitkInvertVFGenericFilter_txx