Point's coordinates between two registered images


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:


 double ijkCoordinates1[3] = {x,y,z};
 double rasCoordinates[3];

 double ijkCoordinates2[3];

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,


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)

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[4] = {x,y,z,1};
double rasCoordinates[4] = {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.