# Point's coordinates between two registered images

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 = {x,y,z};
double rasCoordinates;
ijkToRasMatrix->MultiplyPoint(ijkCorrdinates1,rasCoordinates);

double ijkCoordinates2;
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.

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)``````

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

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 = {x,y,z,1};
double rasCoordinates = {0,0,0,1};``````

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.