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

Open
#2,710 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
c, python

Research direction

The issue identifies DisplacementFieldTransform wrapping and a possible Resample overload, but names no source files or tests. First inspect how SimpleITK wraps TransformBaseTemplate<double> and how sitk.Warp handles field pixel types; check the existing displacement-field tests. Done means float32 fields can be used without conversion to float64, with tests covering the supported resampling use cases.

Written by the indexing model from the issue text.

Description

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.

Dominant language
C++
Stars
1.1k
Forks
235
Avg merge
1d 2h
Merged PRs (30d)
34

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from SimpleITK/SimpleITK

All issues in SimpleITK/SimpleITK

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.