I want to show a image with vtkImageActor, and there is no other prop. I hope the image is shown in the center of screen, so I apply ResetCamera. However, the shown image is strange:

But the image should be:

And the code to reproduce the result is:
import vtkmodules.all as vtk
import numpy as np
from BaseModule import numpyToVTK
img = np.zeros(shape=[50, 50])
img[25:, 0:25] = 64
img[0:25, 25:] = 128
img[25:, 25:] = 255
vtkImg = numpyToVTK(img)
vtkImg.SetOrigin(0, 0, 10)
dx = [0, 1, 0]
dy = [0, 0, 1]
dz = [1, 0, 0]
axialElement = [
dx[0], dy[0], dz[0],
dx[1], dy[1], dz[1],
dx[2], dy[2], dz[2]
]
vtkImg.SetDirectionMatrix(axialElement)
imgActor = vtk.vtkImageActor()
imgActor.SetInputData(vtkImg)
imgActor.Update()
render = vtk.vtkRenderer()
render.AddActor(imgActor)
renWin = vtk.vtkRenderWindow()
renWin.AddRenderer(render)
renWin.Render()
render.ResetCamera()
print('prop bounds: ', imgActor.GetBounds())
print('image bounds: ', vtkImg.GetBounds())
focalPoint = render.GetActiveCamera().GetFocalPoint()
position = render.GetActiveCamera().GetPosition()
print('active camera focal point is: ', focalPoint)
print('active camera position is: ', position)
print('image center is: ', vtkImg.GetCenter())
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(renWin)
iren.SetInteractorStyle(vtk.vtkInteractorStyleTrackballCamera())
iren.Initialize()
iren.Start()
The printed information is:
prop bounds: (0.0, 49.0, 0.0, 49.0, 10.0, 10.0)
image bounds: (0.0, 0.0, 0.0, 49.0, 10.0, 59.0)
active camera focal point is: (24.5, 24.5, 10.0)
active camera position is: (24.5, 24.5, 143.870489570875)
image center is: (0.0, 24.5, 34.5)
We can see that the focal point of camera is not the center of vtkImageData.
Then, I read the source code of ResetCamera. It firstly compute the bounds of all props by this->ComputeVisiblePropBounds(allBounds);, and then set the focal point of camera as the center of bounds.
Unfortunately, the vtkImg.GetBounds() is not the same as imgActor.GetBounds(), because the vtkImageData.GetBounds() do not take the direction of vtkImageData into consideration when calculating the bounds.
Is my understanding correct? Is it a bug of vtk?
