Oriented image data, vtkImageResliceMapper / vtkImageSlice in VTK 9.1.0?

Hi everyone,

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?



Hi everyone,

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?




I think it’s better to “summon” the wanted person by using the syntax @<David Gobbi's moniker>.

take care,


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.

Thanks and best regards, Sophonet

Hi Sophonet,

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.


Hi David,

thanks for the quick reply! Too bad that the aspect of work in progress is not documented.

Best, Sophonet