question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Applying Transform Chain to Geometric Objects

See original GitHub issue

Is your feature request related to a problem? Please describe. Sometimes we need to apply transforms to geometric objects (point clouds, lines, curves, and meshes), particularly in radiotherapy planning and object detection.

Describe the solution you’d like A good solution would be a branch core library that can handle all the geometric transforms while accounting for the image metadata like image spacing and size. A geometric transform chain should be callable in a similar way as we call the regular image transforms. Something like

from monai.transforms.geometric import LoadPoints, RotatePoints

In an ideal case when we have an image annotation pair. We apply the same set of transformation to both objects. But for geometric objects there should be some way of passing messages to the annotations transform chain. For example you are rotating images and annotations. You can apply the rotation to the annotation, but after rotation the size of the image changes in different axes and sometimes it is important that the geometric transform should know about these changes for accurately applying the transforms. So there should be a message passing mechanism between two transform chains. More relevance in discussion #4024

Describe alternatives you’ve considered I have written my own transforms to do all these things but it is a bit hacky and not standardized. I have my geometric labels from open-source tools like labelme. My code handles labelme annotations (in a json) but going in I think we will need to have support for STL, DICOM RT annotations.

Additional context If there are some people working on it, please let me know as I have been working on it and will like to contribute to this branch.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
rijobrocommented, Mar 30, 2022

We really need to make progress on this PR before adding in point transforms (which is definitely on our agenda).

1reaction
ericspodcommented, Apr 6, 2022

The error I get for

import numpy as np
from monai.transforms import Affine
points= np.asarray([[2, 3], [4, 9]])
transforms = Affine(rotate_params=0.35, padding_mode="zeros")
print(transforms(points))

relates to spatial shape because points are understood: ValueError: Unsupported spatial_dims: 1, available options are [2, 3]. The Affine class currently only transforms image data, what we would want to do is extend it to work with points as well, such that if the input has shape [2,N] or [3,N] for some array of points, it can apply the transform to the points treating them as coordinates in space rather than some weird 1D image. How we detect which sort of data we have is something I was discussing with Richard in relation to the MetaTensor idea of combining metadata with a tensor which would state the data type.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Geometric Transformations
An Euclidean transformation is either a translation, a rotation, or a reflection. ... Moreover, the shape of a geometric object will not change....
Read more >
Transform images, shapes, and paths - Adobe Support
The Free Transform command lets you apply transformations (rotate, scale, skew, distort, and perspective) in one continuous operation.
Read more >
Geometric image and points transformations
Sequential and chain the different applied transformations, when this last one ... Use kornia.geometry.transform_points to manipulate points between views.
Read more >
3.5 Chaining the Transformations - Steven M. LaValle
This section links all of the transformations of this chapter together while also slightly adjusting their form to match what is currently used...
Read more >
Transformations and Matrices - Math is Fun
Transformations and Matrices. A matrix can do geometric transformations! ... For each [x,y] point that makes up the shape we do this matrix...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found