InsightSoftwareConsortium / ITK

Insight Toolkit (ITK) -- Official Repository. ITK builds on a proven, spatially-oriented architecture for processing, segmentation, and registration of scientific images in two, three, or more dimensions.
https://itk.org
Apache License 2.0
1.4k stars 661 forks source link

Expose FFT override dimensions in `itk::FFTImageFilterFactory` #3078

Open tbirdso opened 2 years ago

tbirdso commented 2 years ago

Description

Following up from #3065, itk::FFTImageFilterFactory should be updated to allow a developer to specify a list of image dimensions that the user is allowed to input for override.

For instance, VnlForwardFFTImageFilter is the default forward FFT implementation in ITK and should override typical itk::Image dimensions 1 through 4. Meanwhile, in the ITKVkFFTBackend external module VkForwardFFTImageFilter is an accelerated implementation only supporting 1D, 2D, and 3D FFT. Rather than writing a completely new factory, the external developer should be able to pass in a list of dimensions to itk::FFTImageFilterFactory at compile time with the result that instantiating a filter for forward 1D, 2D, or 3D FFT yields a VkForwardFFTImageFilter backend, while instantiating a filter for forward 4D FFT yields a VnlForwardFFTImageFilter backend.

Current behavior

Proposed behavior

Additional Information

Once we have settled on a design pattern here it can be reused elsewhere to assist in implementing swappable backends for any other ITK filters via the object factory.

tbirdso commented 2 years ago

I'm entering this issue to capture follow-up discussion from #3065.

@dzenanz Could this please be assigned to me?

cc @blowekamp @N-Dekker

thewtex commented 2 years ago

This could be achieved with compile-time iteration over integers in a template parameter pack:

https://devtut.github.io/cpp/metaprogramming.html#iterating-over-a-parameter-pack

it gets nicer with C++17 but could still be done with C++14.

It would be best to enable setting this as a build configuration option in CMake with a variable, then use it in the project via itkConfigure.h.in. It should be initialized with the wrapping image dimensions, if possible, and there should be a check that there is an intersection of the wrapping image dimensions and the supported FFT dimensions.