# Linear transform in image plane

**URL:** <https://discourse.slicer.org/t/linear-transform-in-image-plane/25725>\
**Category:** Support\
**Created:** [October 16, 2022, 6:33pm UTC](https://discourse.slicer.org/t/linear-transform-in-image-plane/25725 "2022-10-16T18:33:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![BraDan](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@BraDan](https://discourse.slicer.org/u/BraDan)\
**Post date:** [October 16, 2022, 6:33pm UTC](https://discourse.slicer.org/t/linear-transform-in-image-plane/25725/1 "2022-10-16T18:33:05Z")

</div>

Hello everyone,

This question must be trivial to you - but I would very much appreciate any help on this.

Does anybody know how to translate a segmentation in the image plane using the translation sliders?

The only way for me to achieve this is to rotate the segmentation reference frame to the image plane and then use "translation in local (rotated) reference frame’. Problem is then, of course, that the segmentation is rotated…

![Screenshot](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/6/d678f0efcc8befbf5017701b0a55a3c860a21af7.jpeg)

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [October 17, 2022, 6:07pm UTC](https://discourse.slicer.org/t/linear-transform-in-image-plane/25725/2 "2022-10-17T18:07:38Z")

</div>

One option is to make two nested transforms. The outer one rotates to the desired plane, and then the second inner nested one counter rotates by the same amount. Then if you go back to the first and translate in local reference frame you’ll be moving in the rotated plane.

---

<div class="post-metadata">

**Author:** ![BraDan](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@BraDan](https://discourse.slicer.org/u/BraDan)\
**Post date:** [October 17, 2022, 6:48pm UTC](https://discourse.slicer.org/t/linear-transform-in-image-plane/25725/3 "2022-10-17T18:48:43Z")

</div>

Thanks! Will give this a try as soon as possible.

---

<div class="post-metadata">

**Author:** ![BraDan](https://avatars.discourse-cdn.com/v4/letter/b/22d042/32.png) [@BraDan](https://discourse.slicer.org/u/BraDan)\
**Post date:** [October 18, 2022, 5:41pm UTC](https://discourse.slicer.org/t/linear-transform-in-image-plane/25725/4 "2022-10-18T17:41:31Z")

</div>

Works perfectly, here is what I have done according to your input:

Markups → Create a plane in the rotated volume on any image slice.  
Then get its orientation in relation to the world coordinate system with:

```auto
planeToWorld = vtk.vtkMatrix4x4()
getNode('P').GetObjectToWorldMatrix(planeToWorld)
print(planeToWorld)

```

Copy the rotation transform (3 x 3 submatrix).

Create first LinearTransform ‘counterRotate’: Paste 3 x 3 submatrix in transform matrix. Press ‘Invert’ button. Apply transform to Segmentation.

Create second LinearTransform ‘rotateAndTranslateWithSliders’: Paste 3 x 3 submatrix in transform matrix. Select translation in local (rotated) coordinate system. Apply transform to transformed segmentation.

Now, as expected, the translation sliders translate the segmentation in the plane of the volume slices. Thank you very much again!
