/*========================================================================= 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 clitkMatrixTransformToVFGenericFilter_txx #define clitkMatrixTransformToVFGenericFilter_txx /* ================================================= * @file clitkMatrixTransformToVFGenericFilter.txx * @author * @date * * @brief * ===================================================*/ namespace clitk { //------------------------------------------------------------------- // Update with the number of dimensions //------------------------------------------------------------------- template void MatrixTransformToVFGenericFilter::UpdateWithDim() { // 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 // void // MatrixTransformToVFGenericFilter::UpdateWithDimAndPixelType() // { // ImageTypes typedef itk::Vector Displacement; typedef itk::Image OutputImageType; // Filter #if (ITK_VERSION_MAJOR == 4) && (ITK_VERSION_MINOR < 6) typedef itk::TransformToDisplacementFieldSource ConvertorType; #else typedef itk::TransformToDisplacementFieldFilter ConvertorType; #endif typename ConvertorType::Pointer filter= ConvertorType::New(); // Output image info if (m_ArgsInfo.like_given) { typedef itk::ImageFileReader ReaderType; typename ReaderType::Pointer reader2=ReaderType::New(); reader2->SetFileName(m_ArgsInfo.like_arg); reader2->Update(); typename OutputImageType::Pointer image=reader2->GetOutput(); #if ITK_VERSION_MAJOR > 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR >= 6) filter->SetReferenceImage(image); filter->UseReferenceImageOn(); #else filter->SetOutputParametersFromImage(image); #endif } else { unsigned int i=0; if(m_ArgsInfo.origin_given) { typename OutputImageType::PointType origin; for(i=0;iSetOutputOrigin(origin); } if (m_ArgsInfo.spacing_given) { typename OutputImageType::SpacingType spacing; for(i=0;iSetOutputSpacing(spacing); } if (m_ArgsInfo.size_given) { typename OutputImageType::SizeType size; for(i=0;i 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR >= 6) filter->SetSize(size); #else filter->SetOutputSize(size); #endif } } // Transform typedef itk::AffineTransform TransformType; typename TransformType::Pointer transform =TransformType::New(); itk::Matrix homMatrix= ReadMatrix( m_ArgsInfo.matrix_arg); itk::Matrix matrix =GetRotationalPartMatrix( homMatrix); itk::Vector offset= GetTranslationPartMatrix( homMatrix); transform->SetMatrix(matrix); transform->SetOffset(offset); filter->SetTransform(transform); 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 clitkMatrixTransformToVFGenericFilter_txx