X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvMidPosition.cxx;h=ed5880b562fbc3c11e4ab9199a4eed14cc2e4332;hb=998ca9ca987553dc71578e5584e881f6bd537d91;hp=7d9f772851ac7ff4b18bb33de8b4643b49684e69;hpb=1e034c70105f0926939acaaa27ddb46e904ae8bf;p=clitk.git diff --git a/vv/vvMidPosition.cxx b/vv/vvMidPosition.cxx index 7d9f772..ed5880b 100644 --- a/vv/vvMidPosition.cxx +++ b/vv/vvMidPosition.cxx @@ -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,11 +14,15 @@ - BSD See included LICENSE.txt file - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html -======================================================================-====*/ +===========================================================================**/ #include #include +#if ( ITK_VERSION_MAJOR < 5 ) #include +#else +#include +#endif #include "vvMidPosition.h" #include "clitkCommon.h" @@ -64,7 +68,7 @@ void vvMidPosition::run() error_message="Computation of midposition is only supported for 4D image sequences."; else if (!slicer_manager->GetVF()) error_message="A VF is required for midposition computation"; - else if (slicer_manager->GetVF()->GetScalarTypeAsString() != "float") + else if (slicer_manager->GetVF()->GetScalarTypeAsITKString() != "float") error_message="Please use a vector field of type float."; else { VFType::ConstPointer vf = vvImageToITK(slicer_manager->GetVF()); @@ -74,7 +78,7 @@ void vvMidPosition::run() inv_filter->SetInput(avg_vf); inv_filter->Update(); progress++; - if (slicer_manager->GetImage()->GetScalarTypeAsString() == "short") + if (slicer_manager->GetImage()->GetScalarTypeAsITKString() == "short") this->output=WarpRefImage(inv_filter->GetOutput(),slicer_manager->GetImage(),reference_image_index); else { error_message="Unsupported image pixel type."; @@ -95,8 +99,13 @@ vvImage::Pointer WarpRefImage(OutputVFType::Pointer vf,vvImage::Pointer image,in //We resample the VF because itk's warp filter doesn't like it when the vf and the image have //different spacings +#if ( ITK_VERSION_MAJOR < 5 ) typename itk::VectorResampleImageFilter::Pointer resampler =itk::VectorResampleImageFilter::New(); +#else + typename itk::ResampleImageFilter::Pointer + resampler =itk::ResampleImageFilter::New(); +#endif resampler->SetInput(vf); resampler->SetOutputSpacing(input->GetSpacing()); resampler->SetOutputOrigin(vf->GetOrigin()); @@ -108,7 +117,7 @@ vvImage::Pointer WarpRefImage(OutputVFType::Pointer vf,vvImage::Pointer image,in typename FilterType::Pointer warp_filter = FilterType::New(); warp_filter->SetInput(input); - warp_filter->SetDeformationField(resampler->GetOutput()); + warp_filter->SetDisplacementField(resampler->GetOutput()); warp_filter->SetOutputSpacing(input->GetSpacing()); warp_filter->SetOutputOrigin(input->GetOrigin()); warp_filter->SetOutputSize(input->GetLargestPossibleRegion().GetSize()); @@ -168,7 +177,8 @@ itk::Image,3>::Pointer AverageField(itk::Image::Zero; + VFPixelType zeroVector;//=itk::NumericTraits::Zero; + for(unsigned int i=0;i