Manual registration (apply transform matrix)

I have two volumes and the user needs to be able to transform (translate and/or rotate) one of them for manual registration. What is the right way to do it? I thought about playing with actor.setOrigin(…) , actor.setScale(…) or actor.setUserMatrix(…) but I’m not sure if that is the right way.

In a near future it should also be possible to load a transformation matrix generated by some other library (eg: Elastix).

Context
Those actors represent DICOM series (CT + PET with colormap) from different frame of references that need to be manual registered, these two series may be loaded in one or more viewports (axial, coronal, sagittal and/or oblique views) and moving the PET series should also update all other viewports that have those two series.

Hello,

Please, take a look at this: SetUserMatrix vs using vtkTransformPolyDataFilter - Support - VTK .

best,

PC

Hi Leonardo,

With simple translation I observe some CharEvent (j b n m instead of arrows) and shift one image with respect to the other by one pixel. I capture how many shifts in each direction and display the user the subtraction image.

The code is not too pretty but it should do.

To resume you need:

  1. 2 vtkImageData (mine have the same spacing)
  2. vtkImageTranslateExtent to translate the extent of one image
  3. 2 vtkExtractVOI to extract the overlapping parts of the 2 images. In VTK 8 you didn’t need this step as it was done internally. In VTK 9 you need to find the overlap extent by yourself, my code is here and then extract the VOI.
  4. 2 vtkImageCast to cast to float (signed int might be sufficient)
  5. vtkImageMathematics with operation subtract
  6. display the output of vtkImageMathematics

It would be nice to change the color map, but the grey one seems to do the job.

HTH

Edo

@Paulo_Carvalho and @Edoardo_Pasca,

I’ll take a look at the code and see what I’ll have to change to make it working on VTK.js based on what you guys shared. Thank you for your help.