X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkWarpImageGenericFilter.txx;h=d1d1f714f3a76b46978fd0e9f3335740c1006a2c;hb=71021d34bda3e0e61917cdc1780f7ed901714965;hp=7dbb6d52706486cbcca13f843ecaaacff0b3bdc4;hpb=1e034c70105f0926939acaaa27ddb46e904ae8bf;p=clitk.git diff --git a/tools/clitkWarpImageGenericFilter.txx b/tools/clitkWarpImageGenericFilter.txx index 7dbb6d5..d1d1f71 100644 --- a/tools/clitkWarpImageGenericFilter.txx +++ b/tools/clitkWarpImageGenericFilter.txx @@ -3,7 +3,7 @@ Authors belong to: - University of LYON http://www.universite-lyon.fr/ - - Léon Bérard cancer center http://oncora1.lyon.fnclcc.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 @@ -14,7 +14,7 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #ifndef clitkWarpImageGenericFilter_txx #define clitkWarpImageGenericFilter_txx @@ -27,6 +27,8 @@ * ===================================================*/ +#include "itkVectorResampleImageFilter.h" +#include "clitkConvertBLUTCoeffsToVFFilter.h" namespace clitk { @@ -78,21 +80,32 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType() typedef itk::Image OutputImageType; typedef itk::Vector DisplacementType; typedef itk::Image DeformationFieldType; - - + // 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(); - - //Read the deformation field - typedef itk::ImageFileReader DeformationFieldReaderType; - typename DeformationFieldReaderType::Pointer deformationFieldReader= DeformationFieldReaderType::New(); - deformationFieldReader->SetFileName(m_ArgsInfo.vf_arg); - deformationFieldReader->Update(); - typename DeformationFieldType::Pointer deformationField =deformationFieldReader->GetOutput(); + + typename DeformationFieldType::Pointer deformationField; + if (m_ArgsInfo.coeff_given) { + typedef ConvertBLUTCoeffsToVFFilter FilterType; + typename FilterType::Pointer filter = FilterType::New(); + filter->SetInputFileName(m_ArgsInfo.coeff_arg); + filter->SetLikeFileName(m_InputFileName); + filter->SetVerbose(m_Verbose); + filter->Update(); + deformationField = filter->GetOutput(); + } + else { + //Read the deformation field + typedef itk::ImageFileReader DeformationFieldReaderType; + typename DeformationFieldReaderType::Pointer deformationFieldReader= DeformationFieldReaderType::New(); + deformationFieldReader->SetFileName(m_ArgsInfo.vf_arg); + deformationFieldReader->Update(); + deformationField =deformationFieldReader->GetOutput(); + } // Intensity interpolator typedef clitk::GenericVectorInterpolator GenericInterpolatorType; @@ -139,7 +152,7 @@ WarpImageGenericFilter::UpdateWithDimAndPixelType() // ------------------------------------------- // Spacing like input // ------------------------------------------- - else { + else if (!m_ArgsInfo.coeff_given) { // Get size typename DeformationFieldType::SizeType newSize; for (unsigned int i=0 ; i BackwardWarpFilterType; typename BackwardWarpFilterType::Pointer backwardWarpFilter= BackwardWarpFilterType::New(); - backwardWarpFilter->SetDeformationField( deformationField ); + backwardWarpFilter->SetDisplacementField( deformationField ); backwardWarpFilter->SetEdgePaddingValue( static_cast(m_ArgsInfo.pad_arg) ); backwardWarpFilter->SetOutputSpacing( deformationField->GetSpacing() ); backwardWarpFilter->SetOutputOrigin( input->GetOrigin() );