InterpolateImageFunction of templated PixelType

Hello,

if I want to use an ImageInterpolatorFunction (Linear or NearestNeighbor) for an image with PixelType that can be either scalar or a vector.
The PixelType is determined at compile time because the function template get the PixelType. Using PixelType and known dimension I typedef an ImageType.

Based on the PixelType i would like to typedef the interpolator like this
using Interpolator = itk::SOMEInterpolateImageFunction< TInputImage, TCoordRep>

for the LinearInterpolateImageFunction the documentation states: " This function works for images with scalar and vector pixel types, and for images of type VectorImage."

For the NearestNeighborInterpolateImageFunction the documentation states: " NearestNeighborInterpolateImageFunction interpolates image intensity at a non-integer pixel position by copying the intensity for the nearest neighbor. This class is templated over the input image type and the coordinate representation type (e.g. float or double)."

Hello @Gordian,

My guess is that LinearInterpolateImageFunction did not support vector types at first. I looked through the history of the file and I saw a commit where VectorImage was added. I guess it was the same at some point for images with vector pixel type. So VectorLinearInterpolateImageFunction should probably be deprecated to avoid duplication and confusion.

NearestNeighborInterpolateImageFunction on the other hand may never have been improved to support images with vector pixels. I haven’t tried, maybe it already works. If not, I suspect that it would not be too difficult to add that support. LinearInterpolateImageFunction could serve as a model if necessary. Want to give it a try?

Thanks,
Francois

2 Likes

I think @blowekamp added vector support to LinearInterpolateImageFunction. Maybe he has more information?

Usually operations like nearest neighbor just return the value at an index, so there was never a need for special handling for vector pixels types. I’d guess it always just worked with any pixel type.

Originally, Image of itk::Vector types has separate classes for many operations. As compilers improved and more advanced template programming could be used the basic classes became more robust with different pixel types.

Then with SimpleITK using the “VectorImage” type, many more filters and functions were improved to support this image class which supports a run time number of components per pixel.

We also still have the VectorResampleImageFilter and many other specialized tools that could be deprecated.

1 Like