From 64eedccb7c9d72f4121966ee23c28894395a4acd Mon Sep 17 00:00:00 2001 From: Romulo Pinho Date: Thu, 17 Jan 2013 09:15:48 +0100 Subject: [PATCH] circumventing apparent bug in BSplineTransform of ITK 4.x - SetCoefficientImages doesn't seem to take all images of fields of the flat vector image - Created the flat parameters-image myself and used SetParameters() instead --- .../clitkConvertBLUTCoeffsToVFFilter.txx | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/registration/clitkConvertBLUTCoeffsToVFFilter.txx b/registration/clitkConvertBLUTCoeffsToVFFilter.txx index 491d049..ae1f9d5 100644 --- a/registration/clitkConvertBLUTCoeffsToVFFilter.txx +++ b/registration/clitkConvertBLUTCoeffsToVFFilter.txx @@ -162,8 +162,23 @@ namespace clitk component_filter[i]->Update(); coefficient_images[i] = component_filter[i]->GetOutput(); } + #if ITK_VERSION_MAJOR >= 4 - m_ITKTransform->SetCoefficientImages(coefficient_images); + // 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 -- 2.47.1