【发布时间】:2016-05-26 16:37:56
【问题描述】:
我有 2 个矩阵:
#for example
rotation = matrix([[ 0.61782155, 0.78631834, 0. ],
[ 0.78631834, -0.61782155, 0. ],
[ 0. , 0. , -1. ]])
translation = matrix([[-0.33657291],
[ 1.04497454],
[ 0. ]])
vtkinputpath = "/hello/world/vtkfile.vtk"
vtkoutputpath = "/hello/world/vtkrotatedfile.vtk"
interpolation = "linear"
我有一个包含 3D 图像的 vtk 文件,我想在 python 中创建一个函数来旋转/平移并对其进行插值。
import vtk
def rotate(vtkinputpath, vtkoutputpath, rotation, translation, interpolation):
...
我正在尝试从the transformJ plugin sources(见here to understand how it works)获得灵感
我想使用 vtk.vtkTransform 但我真的不明白它是如何工作的:这些examples 离我想要做的还不够近。这就是我所做的:
reader = vtk.vtkXMLImageDataReader()
reader.SetFileName(vtkinputpath)
reader.Update()
transform = reader.vtkTransform()
transform.RotateX(rotation[0])
transform.RotateY(rotation[1])
transform.RotateZ(rotation[2])
transform.Translate(translation[0], translation[1], translation[2])
#and I don't know how I can choose the parameter of the interpolation
但这行不通... 我看到here RotateWXYZ() 函数存在:
# create a transform that rotates the cone
transform = vtk.vtkTransform()
transform.RotateWXYZ(45,0,1,0)
transformFilter=vtk.vtkTransformPolyDataFilter()
transformFilter.SetTransform(transform)
transformFilter.SetInputConnection(source.GetOutputPort())
transformFilter.Update()
但我不明白这些线条的作用。 我的主要问题是我找不到 Python 的 vtk 文档...
你能给我推荐一个 Python 中 vtk 的文档网站吗?或者你能至少解释一下 vtktransform (rotateWXYZ()) 是如何工作的吗? 拜托,我完全迷路了,没有任何作用。
【问题讨论】:
标签: python image-processing interpolation vtk image-rotation