问题可能已经过时,但看起来scipy.ndimage 中的following function 可能会解决您的问题。
scipy.ndimage.interpolation.rotate 所做的是将完整的 3d 数组围绕 3 个轴中的任何一个旋转一定角度,将存储的值内插到新的“单元格”。它还相应地调整(扩展)新数组的大小,用您指定的值填充新的空单元格。之后,您可以像往常一样进行切片,例如:array[:,sy//2,:]。
简而言之,这里是围绕平行于 z 轴的对角线的中心切割(为简单起见):
sz, sy, sx = array.shape
array[:,sy//2,:] # this is a cut in the x-z plane ...
# ... passing through the middle of the y-axis
# rotating by 45 degrees around the z axis ...
# ... `(2,1)` is `(x,y)` which defines the rotation plane
array_rotated = scipy.ndimage.interpolation.rotate(array, angle=45, axes=(2,1))
sz, sy, sx = array_rotated.shape
# now you'll notice that `sz` is the same ...
# ... but `sx` and `sy` have increased because the diagonal is longer
array_rotated[:,sy//2,:] # this slice is now in the new x'-z' plane ...
# ... but in terms of the original array ...
# ... it passes through the diagonal of x-y along z
您实际上可以进一步思考,并通过围绕不同轴旋转几次将其扩展到任意切片。
PS。如果您觉得花费太多时间,您可以通过传递order=0(默认为order=3)来牺牲插值质量。这将运行得更快。