I would like to show oriented image data in “world” / DICOM coordinates. For that I am using vtkImageResliceMapper and need to set a user matrix from unrotated to rotated coordinates for vtkImageSlice (which uses the mapper). If I do not call vtkImageSlice->SetUserMatrix(unrotated_to_rotated), the slice is not displayed at the correct position.
However, in this case, bounds via vtkImageSlice are not computed correctly, since the vtkImageResliceMapper::GetBounds() considers data directions, and the residual code in vtkImageSlice::GetBounds() applies them again.
Is this a bug in VTK or do I need to change my code?
in the meantime I have tried to nail down the problem further and my current lead is this the following:
I would think that with VTK9 on, vtkImageSlice shall not need a user matrix from unrotated to rotated coordinates, since the vtkImageData knows how to orient itself now.
However, vtkOpenGLImageSliceMapper (which does the rendering in Render()) does not consider image directions as far as I can see, Render() only extracts DataSpacing and DataOrigin from imageData but not DataDirections. I would think that this is a bug in VTK.
Any specific hint how to correctly fix this? Is this assumption above correct? David Gobbi, can you maybe comment?
Thanks Paulo, let me try. @dgobbi, can you comment regarding my questions above and help fix an orientation problem in VTK 9.1.0? I think that the DirectionMatrix needs to be considered in vtkOpenGLSliceMapper, this is not yet the case.
When I write DICOM software in VTK, the Spacing is the only thing that I store in the vtkImageData itself. I keep the orientation and position in a separate vtkMatrix4x4. The DirectionMatrix isn’t yet implemented everywhere in VTK. From what I’ve heard from other developers, it’s still a work in progress.
I had tried to sample a 2D slice from an oriented 3D volume with vtkImageReslice, but realized it does not actually seem to support the DirectionMatrix (according to various Discourse threads)