how to speed up resample interpolator?

When i use BsplineInterpolator to resample my nifit file(315x512x512) to (369X663x663), it takes almost 20 min, that is too low.
how can i to speed up this?

cpu: i5-4590 3.3ghz
The following is my resample code:

typedef itk::ResampleImageFilter<ImageTypeFloat, ImageTypeFloat> ResampleFilterType;
ResampleFilterType::Pointer resamplefilter = ResampleFilterType::New();
using TransformType = itk::AffineTransform<double, 3>;
auto transform = TransformType::New();

typedef itk::BSplineInterpolateImageFunction <ImageTypeFloat, double> InterpolatorType;
InterpolatorType::Pointer interpolator = InterpolatorType::New();
interpolator->SetSplineOrder(order);

resamplefilter->SetTransform(transform);
resamplefilter->SetInterpolator(interpolator);
resamplefilter->SetOutputParametersFromImage(img);
resamplefilter->SetOutputSpacing(newspacing2d);
resamplefilter->SetSize(newshape2d);
resamplefilter->SetInput(img);
resamplefilter->Update();

Have you built ITK in release mode? Processing in debug-mode builds may be 10x slower than in release mode.

You could also consider upgrading your computer. Using a more modern system may make the processing a couple of times faster.

2 Likes