I think the method that the OP is looking for is the following, which can also be used from Python:
vtkImageData::TransformPhysicalPointToContinuousIndex(const double xyz, double ijk)
There are three coordinate systems in play:
- the VTK world coordinates, which are returned by
- the VTK data coordinates, which are returned by
- the image data structured point coordinates, i.e. the voxel indices
Not all pickers have a
GetMapperPosition() method. Which picker are you using?
If you can use
GetMapperPosition(), then you can compute the voxel index like this:
xyz = picker.GetMapperPosition()
XYZ = [0.0, 0.0, 0.0] # to store voxel index
If you cannot use
GetMapperPosition(), you must use the inverse of the actor’s matrix to convert the result of
GetPickPosition() from the world coordinate system to the actor’s local data coordinate system.
The picker will automatically take all camera parameters into account, so you never have to worry about the camera when you use