Problems aligning oblique slice with objects in scene

Hello,

I am trying to render oblique slices from a DICOM with an object in the scene in the right spot and orientation. I know where the object is in DICOM space, and have a 4x4 matrix for it. I have calculated axial, sagittal, and coronal view matrices using this object’s transform as a basis (the slices are in its planes).

Using the vtkImageReslice, the output gives me the slice that is expected for each transform, but I could not get the object in the right spot. I pivoted to using the vtkImageResliceMapper and the vtkImageSlice, but I cannot get everything configured correctly. The object is in the 3D volume, and the goal is to get a render of it positioned and rotated correctly in the slice.

I’m doing variations of this:

objectInScene.SetuserMatrix(VtkUtils.CreateMatrixFromArray(dicomSpaceTransform));
var cameraMatrix = GetViewportMatrixForOrientation(dicomSpaceTransform);
_sliceMapper.SliceFacesCameraOn();
_sliceMapper.SliceAtFocalPointOn();
var t = vtkTransform.New();
t.Concatenate(VtkUtils.CreateMatrixFromArray(cameraMatrix)); // cameraMatrixis the 4x4 calculated  for the axial/sagittal/coronal orientation
_imageViewer.GetRenderer().GetActiveCamera().SetFocalPoint(cameraMatrix[3], cameraMatrix[7],  cameraMatrix[11]); // offset for the camera
_imageViewer.GetRenderer().GetActiveCamera().SetUserViewTransform(t);

I used this same matrix with the SetResliceAxesDirectionCosines and SetResliceAxesOrigin, where it produced the desired slice (but I couldn’t get the instrument rendered in the right spot). But trying to use this transform with the camera just results in a black render, it’s not looking at anything in the scene.

Here’s an illustration of what I’m trying to acheive:


That’s from my attempt using vtkImageReslice, it was close, but coronal never had the object (the crosshair) in the right spot. I’m much further off trying to use the vtkImageSliceMapper, I’m clearly not using it right, any guidance on how to get this working?

I wound up achieving the desired result by not using the SliceFacesCamera and SliceAtFocalPoint methods. Instead I set the plane origin and normal to the offset and Z vector of the desired camera matrix I had calculated. The scene camera gets the same offset, just backed out a bit so it’s seeing everything. The look vector is automatically computed from the default focal point and the camera offset. Then I just set the view up as appropriate for axial/sagittal/coronal. And VTK just crosses those two to get the third vector.

1 Like