[Feat] Volumetric (3D + channels) Affine warping
See original GitHub issue🚀 Feature Request
Add support for volumetric data (C, (D,) H, W) and affine transformations
Motivation
Volumetric transformations can be used for any kind of volumetric data (e.g. medical -> CT, MRI) and affine transformations are very common for augmentation transformations (e.g. in rising).
Pitch
Introduce a new base class GenericWarper
from which DepthWarper
, HomographyWarper
and AffineWarper
can be derived from.
The functional API of the warp functions shouldn’t be changed because it can automatically detect if the input tensor has an additional dimension or not.
I’m not quite sure how the volumetric support should be added for the future. One possibility would be to add a first version exists besides the 2D functions and has support for both 2D and 3D (could probably look similar to rising’s functionals) or add additional functions to specifically/only handle 3D data (this would probably lead to quite a lot of code duplication).
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
my idea was to refactor
kornia.geometry.warp
with something like this. /cc @ducha-aiki @lferraz had some initial thoughts as well since he refactored few weeks ago to handle cases where you want to reuse the grid to speed up processes.Then any type of transformation can be specialized from this by just adjusting the way it produces the grid depending on the desired behavior.
Then to follow OpenCV convention the high level interfaces would be:
@mibaumgartner I have internally implemented already the
warp_projective
functionality plus few utlils likeget_projection_matrix
which is an extension ofget_rotation_matrix2d
that basically does the logics to compute the transformation matrix given an angle vector in angle-axis format and the 3d coordinate to the origin from where you want to apply the transformation. Besides, I needed to implement some normalization tricks to compute the final transformation is we do for the 2d affine case in here but for the 3D case. Hope I can send a PR soon about it.