Skip to content

Single-precision displacement field transforms: a float32 field pays a float64 conversion today #2710

Description

@vboussot

SimpleITK wraps only TransformBaseTemplate<double>, so a float32 displacement field handed to DisplacementFieldTransform is converted to float64 and interleaved at that width before anything is resampled.

At the scale of registration fields this is the dominant cost of the operation. Measured on a 122-row region of a large field (SimpleITK 2.5.5): building the double-precision transform allocates 6.9 GiB and takes 5.0 s, which is 39% of everything that region costs end to end in our pipeline. The field itself is float32 on disk and float32 is plenty for the geometry.

sitk.Warp escapes because it is templated on the field's own pixel type, but it only covers the narrowest case: field grid == output grid, whole map, linear interpolation. Any composite or resampled-field use pays the float64 build.

ITK already instantiates DisplacementFieldTransform<float, N>. Exposing it (or a Resample overload accepting a sitkVectorFloat32 field directly) would halve the memory and remove the conversion for every consumer that resamples through stored fields. Happy to help test a PR if the wrapping approach is agreed on.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions