X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=registration%2FclitkConvertBLUTCoeffsToVFFilter.txx;h=d10bcbb69f1f24579f5a8c3b82d4f668b7c7145c;hb=08fe9b32ad42470967fd75b6b5bedd6dbfbd664e;hp=e1034240c8af60df45358776d106ec654dae6c37;hpb=db1e29b00e5b2ca2b20533fa882e624ebba93a7f;p=clitk.git diff --git a/registration/clitkConvertBLUTCoeffsToVFFilter.txx b/registration/clitkConvertBLUTCoeffsToVFFilter.txx index e103424..d10bcbb 100644 --- a/registration/clitkConvertBLUTCoeffsToVFFilter.txx +++ b/registration/clitkConvertBLUTCoeffsToVFFilter.txx @@ -7,11 +7,6 @@ //#include "clitkConvertBSplineDeformableTransformToVFGenericFilter.h" #include "clitkVectorImageToImageFilter.h" -#if ITK_VERSION_MAJOR >= 4 -#include "itkTransformToDisplacementFieldSource.h" -#else -#include "itkTransformToDeformationFieldSource.h" -#endif #include "itkBSplineDeformableTransform.h" namespace clitk @@ -149,7 +144,12 @@ namespace clitk typedef clitk::VectorImageToImageFilter FilterType; typename FilterType::Pointer component_filter[BLUTCoefficientImageType::ImageDimension]; +#if ITK_VERSION_MAJOR >= 4 + typename ITKTransformType::CoefficientImageArray coefficient_images; +#else typename ITKTransformType::ImagePointer coefficient_images[BLUTCoefficientImageType::ImageDimension]; +#endif + for (unsigned int i=0; i < BLUTCoefficientImageType::ImageDimension; i++) { component_filter[i] = FilterType::New(); component_filter[i]->SetInput(input); @@ -157,20 +157,43 @@ namespace clitk component_filter[i]->Update(); coefficient_images[i] = component_filter[i]->GetOutput(); } + +#if ITK_VERSION_MAJOR >= 4 + // RP: 16/01/2013 + // ATTENTION: Apparently, there's a bug in the SetCoefficientImages function of ITK 4.x + // I needed to use SetParametersByValue instead. + // + typename ITKTransformType::ParametersType params(input->GetPixelContainer()->Size() * BLUTCoefficientImageType::ImageDimension); + for (unsigned int i=0; i < BLUTCoefficientImageType::ImageDimension; i++) { + for (unsigned int j=0; j < coefficient_images[i]->GetPixelContainer()->Size(); j++) + params[input->GetPixelContainer()->Size() * i + j] = coefficient_images[i]->GetPixelContainer()->GetBufferPointer()[j]; + } + + m_ITKTransform->SetGridOrigin(input->GetOrigin()); + m_ITKTransform->SetGridDirection(input->GetDirection()); + m_ITKTransform->SetGridRegion(input->GetLargestPossibleRegion()); + m_ITKTransform->SetGridSpacing(input->GetSpacing()); + m_ITKTransform->SetParametersByValue(params); +#else m_ITKTransform->SetCoefficientImage(coefficient_images); +#endif m_GenericTransform = m_ITKTransform; } +#if ITK_VERSION_MAJOR > 4 || (ITK_VERSION_MAJOR == 4 && ITK_VERSION_MINOR >= 6) + m_Filter->SetReferenceImage(output); +#else m_Filter->SetOutputOrigin(output->GetOrigin()); m_Filter->SetOutputSpacing(output->GetSpacing()); m_Filter->SetOutputSize(output->GetLargestPossibleRegion().GetSize()); +#endif m_Filter->SetTransform(m_GenericTransform); m_Filter->Update(); - SetNthOutput(0, m_Filter->GetOutput()); + this->SetNthOutput(0, m_Filter->GetOutput()); } -} \ No newline at end of file +}