# Point's coordinates between two registered images

**URL:** <https://discourse.slicer.org/t/points-coordinates-between-two-registered-images/544>\
**Category:** Development\
**Created:** [June 21, 2017, 8:10am UTC](https://discourse.slicer.org/t/points-coordinates-between-two-registered-images/544 "2017-06-21T08:10:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandra](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@sandra](https://discourse.slicer.org/u/sandra)\
**Post date:** [June 21, 2017, 8:10am UTC](https://discourse.slicer.org/t/points-coordinates-between-two-registered-images/544/1 "2017-06-21T08:10:56Z")

</div>

Hi!

I have two images registered together and I would like to, given the IJK coordinates of a point in the first image, get its IJK coordinates in the second one.  
To do so, I did this:

```
 firstVolume->GetIJKToRASMatrix(ijkToRasMatrix);
 secondVolume->GetRASToIJKMatrix(rasToIjkMatrix);

 double ijkCoordinates1[3] = {x,y,z};
 double rasCoordinates[3];
 ijkToRasMatrix->MultiplyPoint(ijkCorrdinates1,rasCoordinates);

 double ijkCoordinates2[3];
 rasToIjkMatrix->MultiplyPoint(rasCoordinates,ijkCoordinates2);

```

But the point I obtain in the second image doesn’t match the point in the first one.  
Is this the correct way to do want I want to do ?

Thanks for your help,

Sandra.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 21, 2017, 11:37pm UTC](https://discourse.slicer.org/t/points-coordinates-between-two-registered-images/544/2 "2017-06-21T23:37:05Z")

</div>

If the two volume nodes have different parent transforms, then you need to take into account the transform between them:

```
firstVolumeToSecondVolumeTransformMatrix = vtk.vtkMatrix4x4()
slicer.vtkMRMLTransformNode.GetMatrixTransformBetweenNodes(firstVolume.GetParentTransformNode(), secondVolume.GetParentTransformNode(), firstVolumeToSecondVolumeTransformMatrix)
```

---

<div class="post-metadata">

**Author:** ![sandra](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@sandra](https://discourse.slicer.org/u/sandra)\
**Post date:** [June 22, 2017, 8:39am UTC](https://discourse.slicer.org/t/points-coordinates-between-two-registered-images/544/3 "2017-06-22T08:39:50Z")

</div>

Ok,  
but when I do firstVolume.GetParentTransformNode() I get a null node (same thing for the second volume) so the transform matrix between these nodes is identity

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [June 22, 2017, 12:06pm UTC](https://discourse.slicer.org/t/points-coordinates-between-two-registered-images/544/4 "2017-06-22T12:06:13Z")

</div>

That is good then, they are in the same coordinate system.

However, there is a problem with your coordinates. Homogeneous point coordinates have 4 components, not just 3. The value of the 4th component must be 1.

For example:

```
double ijkCoordinates1[4] = {x,y,z,1};
double rasCoordinates[4] = {0,0,0,1};
```

---

<div class="post-metadata">

**Author:** ![sandra](https://avatars.discourse-cdn.com/v4/letter/s/4491bb/32.png) [@sandra](https://discourse.slicer.org/u/sandra)\
**Post date:** [June 22, 2017, 12:40pm UTC](https://discourse.slicer.org/t/points-coordinates-between-two-registered-images/544/5 "2017-06-22T12:40:35Z")

</div>

That works perfectly, thank you very much !  
I thought I was missing some kind of transformation between the two images and I wouldn’t have thought about this.
