X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=tools%2FclitkInvertVFGenericFilter.txx;h=558b34177d48357acd174f7c6fc14f669e20e428;hb=42f68068ef3488c8ca2d921b6835d34fe6494d5f;hp=9835c2e739f64d3edd1af378e7955efc43059ba7;hpb=47ac2413c129f2e330a760b665f03e6032aa46fb;p=clitk.git diff --git a/tools/clitkInvertVFGenericFilter.txx b/tools/clitkInvertVFGenericFilter.txx index 9835c2e..558b341 100644 --- a/tools/clitkInvertVFGenericFilter.txx +++ b/tools/clitkInvertVFGenericFilter.txx @@ -18,6 +18,8 @@ #ifndef clitkInvertVFGenericFilter_txx #define clitkInvertVFGenericFilter_txx +#include "itkVectorResampleImageFilter.h" + /* ================================================= * @file clitkInvertVFGenericFilter.txx * @author @@ -117,7 +119,7 @@ InvertVFGenericFilter::UpdateWithDimAndPixelType() typename InputReaderType::Pointer reader = InputReaderType::New(); reader->SetFileName( m_InputFileName); reader->Update(); - typename InputImageType::Pointer input= reader->GetOutput(); + typename InputImageType::Pointer input = reader->GetOutput(); // Filter typename OutputImageType::Pointer output; @@ -128,7 +130,30 @@ InvertVFGenericFilter::UpdateWithDimAndPixelType() // Create the InvertVFFilter typedef clitk::InvertVFFilter FilterType; typename FilterType::Pointer filter =FilterType::New(); - filter->SetInput(input); + if (m_ArgsInfo.like_given) { + typename FilterType::SpacingType spacing; + typename FilterType::SizeType size; + itk::ImageIOBase::Pointer header = readImageHeader(m_ArgsInfo.like_arg); + for(unsigned int i=0; iGetDimensions(i); + spacing[i] = header->GetSpacing(i); + } + + typedef itk::VectorResampleImageFilter ResampleFilterType; + typename ResampleFilterType::Pointer resampler = ResampleFilterType::New(); + resampler->SetInput(input); + resampler->SetOutputOrigin(input->GetOrigin()); + resampler->SetOutputDirection(input->GetDirection()); + resampler->SetOutputSpacing(spacing); + resampler->SetSize(size); + resampler->Update(); + spacing = resampler->GetOutput()->GetSpacing(); + size = resampler->GetOutput()->GetLargestPossibleRegion().GetSize(); + filter->SetInput(resampler->GetOutput()); + } + else + filter->SetInput(input); + filter->SetVerbose(m_Verbose); if (m_ArgsInfo.threads_given) filter->SetNumberOfThreads(m_ArgsInfo.threads_arg); if (m_ArgsInfo.pad_given) {