Allowing generic output type in VectorLinearInterpolateImageFunction::EvaluateAtContinuousIndex
#4593
Labels
type:Design
Improvement in the design of a given area
Description
The current design restricts the output type of the interpolation to
double
. As shown hereNumericTraits<typename TInputImage::PixelType>::RealType
evaluates todouble
regardless of the input type.We found this was an issue while profiling ANTs registrationSyN. Using ITK templating, the pipeline offers the option for computation to be done in either float or double. Unexpectedly, the execution time of the pipeline is significantly longer when using
float
compared todouble
(See figure below). Our observation shows that the time difference is due to the cast from float to double, and possible back to float in ANTs.Looking at gdb output we see that the input data is an 3D image of type
float
but the output is of type
double
.Impact analysis
Currently, the downside is that only
double
is accepted as an output type for the interpolation.One the one hand, allowing generic type for the output would prevent confusion and potential slowdowns, as with the ANTs case above. Alternatively, the same type as the input data could be use, with similar benefits.
On the other hand, using different output type could affect the precision of the calculation if lower-precision data type are used, or increase the runtime if higher-precision data type are used. i.e. trade-off between performance and precision.
Due to the potential change in precision incurred by this change, this may affected substantially some tools depending on this function.
Expected behavior
Actual behavior
Versions
Additional Information
The text was updated successfully, but these errors were encountered: