From: Romulo Pinho Date: Thu, 17 Jan 2013 08:15:48 +0000 (+0100) Subject: circumventing apparent bug in BSplineTransform of ITK 4.x X-Git-Tag: v1.4.0~254^2~5 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=64eedccb7c9d72f4121966ee23c28894395a4acd;p=clitk.git 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 --- 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