X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkValuesToBSplineCoefficientsGenericFilter.txx;fp=tools%2FclitkValuesToBSplineCoefficientsGenericFilter.txx;h=782aad88e702058bc95025da3a0feea54ad92bd1;hb=a26cd8a19e1b9ad8344ab501436045f171a73713;hp=0000000000000000000000000000000000000000;hpb=f1016340d797dbe6e0672e6e06a583baaafc738b;p=clitk.git diff --git a/tools/clitkValuesToBSplineCoefficientsGenericFilter.txx b/tools/clitkValuesToBSplineCoefficientsGenericFilter.txx new file mode 100644 index 0000000..782aad8 --- /dev/null +++ b/tools/clitkValuesToBSplineCoefficientsGenericFilter.txx @@ -0,0 +1,155 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://oncora1.lyon.fnclcc.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +======================================================================-====*/ +#ifndef clitkValuesToBSplineCoefficientsGenericFilter_txx +#define clitkValuesToBSplineCoefficientsGenericFilter_txx + +/* ================================================= + * @file clitkValuesToBSplineCoefficientsGenericFilter.txx + * @author + * @date + * + * @brief + * + ===================================================*/ + + +namespace clitk +{ + + //------------------------------------------------------------------- + // Update with the number of dimensions + //------------------------------------------------------------------- + template + void + ValuesToBSplineCoefficientsGenericFilter::UpdateWithDim(std::string PixelType, unsigned int Components) + { + 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(); + } + } + + else if (Components==3) + { + if (m_Verbose) std::cout << "Launching filter in "<< Dimension <<"D and 3D float (DVF)" << std::endl; + UpdateWithDimAndVectorType >(); + } + + else std::cerr<<"Number of components is "< + void + ValuesToBSplineCoefficientsGenericFilter::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 + typedef itk::BSplineDecompositionImageFilter 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 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 + void + ValuesToBSplineCoefficientsGenericFilter::UpdateWithDimAndVectorType() + { + + // 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 + typedef clitk::VectorBSplineDecompositionImageFilter 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 WriterType; + typename WriterType::Pointer writer = WriterType::New(); + writer->SetFileName(m_ArgsInfo.output_arg); + writer->SetInput(output); + writer->Update(); + + } + + +}//end clitk + +#endif //#define clitkValuesToBSplineCoefficientsGenericFilter_txx