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, cameraMatrix, cameraMatrix); // 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?